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

Unified Diff: src/objects.h

Issue 11299163: Optimize non-ASCII string splitting with single-character search pattern (Closed)
Patch Set: Created 8 years, 1 month 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 | « no previous file | src/runtime.cc » ('j') | src/runtime.cc » ('J')
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 7d46c068589bfb707a43e93d84bf5cc74e328275..5f04fe1e61d929ba47e86c45e3e804ac5644da0d 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -7189,6 +7189,13 @@ class String: public HeapObject {
ASSERT_EQ(TWO_BYTE, state_);
return Vector<const uc16>::cast(buffer_);
}
+ // Return the character length of the string.
+ unsigned Length() const {
+ if (state_ == ASCII) return buffer_.length();
+ if (state_ == TWO_BYTE) return buffer_.length() / 2;
Yang 2012/11/26 08:45:30 you could do an if (state_ == ASCII) { ... } els
+ UNREACHABLE();
+ return 0; // Placate compiler.
+ }
private:
enum State { NON_FLAT, ASCII, TWO_BYTE };
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698