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

Unified Diff: src/objects.h

Issue 11194053: Keep track of the first non-ascii word/char to avoid redoing the work. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 2 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 side-by-side diff with in-line comments
Download patch
« src/heap.cc ('K') | « src/heap-inl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 56b54323f0cf59711e6ee9047eb5524b29ca0020..03946ef559261efc7b495831575d6fcde5a0bad8 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -7413,32 +7413,42 @@ class String: public HeapObject {
int from,
int to);
- static inline bool IsAscii(const char* chars, int length) {
+ static inline const char* NonAsciiStart(const char* chars, int length) {
Yang 2012/10/18 14:46:23 Please add a comment on what the return value is (
Toon Verwaest 2012/10/18 15:06:56 Done.
const char* limit = chars + length;
#ifdef V8_HOST_CAN_READ_UNALIGNED
ASSERT(kMaxAsciiCharCode == 0x7F);
const uintptr_t non_ascii_mask = kUintptrAllBitsSet / 0xFF * 0x80;
while (chars + sizeof(uintptr_t) <= limit) {
if (*reinterpret_cast<const uintptr_t*>(chars) & non_ascii_mask) {
- return false;
+ return chars;
}
chars += sizeof(uintptr_t);
}
#endif
while (chars < limit) {
- if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) return false;
+ if (static_cast<uint8_t>(*chars) > kMaxAsciiCharCodeU) return chars;
++chars;
}
- return true;
+ return chars;
}
- static inline bool IsAscii(const uc16* chars, int length) {
+ static inline bool IsAscii(const char* chars, int length) {
+ const char* limit = chars + length;
+ return NonAsciiStart(chars, length) >= limit;
+ }
+
+ static inline const uc16* NonAsciiStart(const uc16* chars, int length) {
const uc16* limit = chars + length;
while (chars < limit) {
- if (*chars > kMaxAsciiCharCodeU) return false;
+ if (*chars > kMaxAsciiCharCodeU) return chars;
++chars;
}
- return true;
+ return chars;
+ }
+
+ static inline bool IsAscii(const uc16* chars, int length) {
+ const uc16* limit = chars + length;
+ return NonAsciiStart(chars, length) >= limit;
}
protected:
« src/heap.cc ('K') | « src/heap-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698