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

Unified Diff: src/objects-inl.h

Issue 524059: Speed up compares with characters ie single-character strings.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
===================================================================
--- src/objects-inl.h (revision 3561)
+++ src/objects-inl.h (working copy)
@@ -150,8 +150,12 @@
bool Object::IsSymbol() {
if (!this->IsHeapObject()) return false;
uint32_t type = HeapObject::cast(this)->map()->instance_type();
- return (type & (kIsNotStringMask | kIsSymbolMask)) ==
- (kStringTag | kSymbolTag);
+ // Because the symbol tag is non-zero and no non-string types have the
+ // symbol bit set we can test for symbols with a very simple test
+ // operation.
+ ASSERT(kSymbolTag != 0);
+ ASSERT(kNotStringTag + kIsSymbolMask > LAST_TYPE);
+ return (type & kIsSymbolMask != 0);
}
@@ -226,7 +230,8 @@
bool StringShape::IsSymbol() {
ASSERT(valid());
- return (type_ & kIsSymbolMask) == kSymbolTag;
+ ASSERT(kSymbolTag != 0);
+ return (type_ & kIsSymbolMask) != 0;
}
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698