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

Side by Side Diff: Source/platform/text/SegmentedString.h

Issue 1320813002: SegmentedString: Use decrementAndCheckLength where possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | Annotate | Revision Log
« 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) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 }; 212 };
213 213
214 LookAheadResult lookAhead(const String& string) { return lookAheadInline(str ing, TextCaseSensitive); } 214 LookAheadResult lookAhead(const String& string) { return lookAheadInline(str ing, TextCaseSensitive); }
215 LookAheadResult lookAheadIgnoringCase(const String& string) { return lookAhe adInline(string, TextCaseInsensitive); } 215 LookAheadResult lookAheadIgnoringCase(const String& string) { return lookAhe adInline(string, TextCaseInsensitive); }
216 216
217 void advance() 217 void advance()
218 { 218 {
219 if (m_fastPathFlags & Use8BitAdvance) { 219 if (m_fastPathFlags & Use8BitAdvance) {
220 ASSERT(!m_pushedChar1); 220 ASSERT(!m_pushedChar1);
221 m_currentChar = m_currentString.incrementAndGetCurrentChar8(); 221 m_currentChar = m_currentString.incrementAndGetCurrentChar8();
222 m_currentString.decrementLength(); 222 decrementAndCheckLength();
223 if (!m_currentString.haveOneCharacterLeft())
224 return;
225
226 updateSlowCaseFunctionPointers();
227
228 return; 223 return;
229 } 224 }
230 225
231 (this->*m_advanceFunc)(); 226 (this->*m_advanceFunc)();
232 } 227 }
233 228
234 inline void advanceAndUpdateLineNumber() 229 inline void advanceAndUpdateLineNumber()
235 { 230 {
236 if (m_fastPathFlags & Use8BitAdvance) { 231 if (m_fastPathFlags & Use8BitAdvance) {
237 ASSERT(!m_pushedChar1); 232 ASSERT(!m_pushedChar1);
238 233
239 bool haveNewLine = (m_currentChar == '\n') & !!(m_fastPathFlags & Us e8BitAdvanceAndUpdateLineNumbers); 234 bool haveNewLine = (m_currentChar == '\n') & !!(m_fastPathFlags & Us e8BitAdvanceAndUpdateLineNumbers);
240 m_currentChar = m_currentString.incrementAndGetCurrentChar8(); 235 m_currentChar = m_currentString.incrementAndGetCurrentChar8();
241 m_currentString.decrementLength(); 236 decrementAndCheckLength();
242 bool haveOneCharacterLeft = m_currentString.haveOneCharacterLeft();
243 237
244 if (haveNewLine) { 238 if (haveNewLine) {
tkent 2015/08/27 03:08:01 This block doesn't refer to data members updated b
245 ++m_currentLine; 239 ++m_currentLine;
246 m_numberOfCharactersConsumedPriorToCurrentLine = m_numberOfChar actersConsumedPriorToCurrentString + m_currentString.numberOfCharactersConsumed( ); 240 m_numberOfCharactersConsumedPriorToCurrentLine = m_numberOfChar actersConsumedPriorToCurrentString + m_currentString.numberOfCharactersConsumed( );
247 } 241 }
248 242
249 if (haveOneCharacterLeft)
250 updateSlowCaseFunctionPointers();
251
252 return; 243 return;
253 } 244 }
254 245
255 (this->*m_advanceAndUpdateLineNumberFunc)(); 246 (this->*m_advanceAndUpdateLineNumberFunc)();
256 } 247 }
257 248
258 void advanceAndASSERT(UChar expectedCharacter) 249 void advanceAndASSERT(UChar expectedCharacter)
259 { 250 {
260 ASSERT_UNUSED(expectedCharacter, currentChar() == expectedCharacter); 251 ASSERT_UNUSED(expectedCharacter, currentChar() == expectedCharacter);
261 advance(); 252 advance();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 bool m_closed; 408 bool m_closed;
418 bool m_empty; 409 bool m_empty;
419 unsigned char m_fastPathFlags; 410 unsigned char m_fastPathFlags;
420 void (SegmentedString::*m_advanceFunc)(); 411 void (SegmentedString::*m_advanceFunc)();
421 void (SegmentedString::*m_advanceAndUpdateLineNumberFunc)(); 412 void (SegmentedString::*m_advanceAndUpdateLineNumberFunc)();
422 }; 413 };
423 414
424 } 415 }
425 416
426 #endif 417 #endif
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