Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: Source/core/dom/SpaceSplitString.cpp

Issue 1167693004: Make SpaceSplitString::set() faster (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 David Smith (catfish.man@gmail.com) 2 * Copyright (C) 2007 David Smith (catfish.man@gmail.com)
3 * Copyright (C) 2007, 2008, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2007, 2008, 2011, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 return map; 151 return map;
152 } 152 }
153 153
154 void SpaceSplitString::set(const AtomicString& inputString, CaseFolding caseFold ing) 154 void SpaceSplitString::set(const AtomicString& inputString, CaseFolding caseFold ing)
155 { 155 {
156 if (inputString.isNull()) { 156 if (inputString.isNull()) {
157 clear(); 157 clear();
158 return; 158 return;
159 } 159 }
160 160
161 String string(inputString.string()); 161 if (caseFolding == ShouldFoldCase && hasNonASCIIOrUpper(inputString.string() )) {
162 if (caseFolding == ShouldFoldCase && hasNonASCIIOrUpper(string)) 162 String string(inputString.string());
163 string = string.foldCase(); 163 string = string.foldCase();
164 164 m_data = Data::create(AtomicString(string));
165 m_data = Data::create(AtomicString(string)); 165 } else {
166 m_data = Data::create(inputString);
167 }
166 } 168 }
167 169
168 SpaceSplitString::Data::~Data() 170 SpaceSplitString::Data::~Data()
169 { 171 {
170 if (!m_keyString.isNull()) 172 if (!m_keyString.isNull())
171 sharedDataMap().remove(m_keyString); 173 sharedDataMap().remove(m_keyString);
172 } 174 }
173 175
174 PassRefPtr<SpaceSplitString::Data> SpaceSplitString::Data::create(const AtomicSt ring& string) 176 PassRefPtr<SpaceSplitString::Data> SpaceSplitString::Data::create(const AtomicSt ring& string)
175 { 177 {
(...skipping 19 matching lines...) Expand all
195 197
196 SpaceSplitString::Data::Data(const SpaceSplitString::Data& other) 198 SpaceSplitString::Data::Data(const SpaceSplitString::Data& other)
197 : RefCounted<Data>() 199 : RefCounted<Data>()
198 , m_vector(other.m_vector) 200 , m_vector(other.m_vector)
199 { 201 {
200 // Note that we don't copy m_keyString to indicate to the destructor that th ere's nothing 202 // Note that we don't copy m_keyString to indicate to the destructor that th ere's nothing
201 // to be removed from the sharedDataMap(). 203 // to be removed from the sharedDataMap().
202 } 204 }
203 205
204 } // namespace blink 206 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698