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

Side by Side Diff: third_party/WebKit/Source/wtf/text/ASCIIFastPath.h

Issue 2585063002: Cache contains only ascii in StringImpl (Closed)
Patch Set: DCHECK + static_Cast Created 3 years, 11 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 | third_party/WebKit/Source/wtf/text/StringImpl.h » ('j') | 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) 2011, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 3 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 template <typename CharacterType> 71 template <typename CharacterType>
72 inline bool isAllASCII(MachineWord word) { 72 inline bool isAllASCII(MachineWord word) {
73 return !(word & NonASCIIMask<sizeof(MachineWord), CharacterType>::value()); 73 return !(word & NonASCIIMask<sizeof(MachineWord), CharacterType>::value());
74 } 74 }
75 75
76 // Note: This function assume the input is likely all ASCII, and 76 // Note: This function assume the input is likely all ASCII, and
77 // does not leave early if it is not the case. 77 // does not leave early if it is not the case.
78 template <typename CharacterType> 78 template <typename CharacterType>
79 inline bool charactersAreAllASCII(const CharacterType* characters, 79 inline bool charactersAreAllASCII(const CharacterType* characters,
80 size_t length) { 80 size_t length) {
81 DCHECK_GT(length, 0u);
81 MachineWord allCharBits = 0; 82 MachineWord allCharBits = 0;
82 const CharacterType* end = characters + length; 83 const CharacterType* end = characters + length;
83 84
84 // Prologue: align the input. 85 // Prologue: align the input.
85 while (!isAlignedToMachineWord(characters) && characters != end) { 86 while (!isAlignedToMachineWord(characters) && characters != end) {
86 allCharBits |= *characters; 87 allCharBits |= *characters;
87 ++characters; 88 ++characters;
88 } 89 }
89 90
90 // Compare the values of CPU word size. 91 // Compare the values of CPU word size.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 for (size_t i = 0; i < length; ++i) { 174 for (size_t i = 0; i < length; ++i) {
174 DCHECK(!(source[i] & 0xff00)); 175 DCHECK(!(source[i] & 0xff00));
175 destination[i] = static_cast<LChar>(source[i]); 176 destination[i] = static_cast<LChar>(source[i]);
176 } 177 }
177 #endif 178 #endif
178 } 179 }
179 180
180 } // namespace WTF 181 } // namespace WTF
181 182
182 #endif // ASCIIFastPath_h 183 #endif // ASCIIFastPath_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/text/StringImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698