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

Unified Diff: src/conversions.cc

Issue 9038: Create an abstraction for the string type flags so that they can be cached.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 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
Index: src/conversions.cc
===================================================================
--- src/conversions.cc (revision 654)
+++ src/conversions.cc (working copy)
@@ -55,7 +55,8 @@
static inline int GetChar(String* str, int index) {
- return str->Get(index);
+ StringShape shape(str);
+ return str->Get(shape, index);
}
@@ -75,15 +76,18 @@
static inline const char* GetCString(String* str, int index) {
- char* result = NewArray<char>(str->length() + 1);
- for (int i = index; i < str->length(); i++) {
- if (str->Get(i) <= 127) {
- result[i - index] = static_cast<char>(str->Get(i));
+ StringShape shape(str);
+ int length = str->length(shape);
+ char* result = NewArray<char>(length + 1);
+ for (int i = index; i < length; i++) {
+ uc16 c = str->Get(shape, i);
+ if (c <= 127) {
+ result[i - index] = static_cast<char>(c);
} else {
result[i - index] = 127; // Force number parsing to fail.
}
}
- result[str->length() - index] = '\0';
+ result[length - index] = '\0';
return result;
}
@@ -104,7 +108,8 @@
static inline bool IsSpace(String* str, int index) {
- return Scanner::kIsWhiteSpace.get(str->Get(index));
+ StringShape shape(str);
+ return Scanner::kIsWhiteSpace.get(str->Get(shape, index));
}
@@ -116,11 +121,12 @@
static inline bool SubStringEquals(String* str, int index, const char* other) {
+ StringShape shape(str);
HandleScope scope;
int len = strlen(other);
Mads Ager (chromium) 2008/11/03 08:45:49 Introduced other_len and str_len?
- int end = index + len < str->length() ? index + len : str->length();
+ int end = index + len < str->length(shape) ? index + len : str->length(shape);
Handle<String> slice =
- Factory::NewStringSlice(Handle<String>(str), index, end);
+ Factory::NewStringSlice(Handle<String>(str), shape, index, end);
return slice->IsEqualTo(Vector<const char>(other, len));
}

Powered by Google App Engine
This is Rietveld 408576698