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

Side by Side Diff: src/api.cc

Issue 1594017: Flatten before String::WriteUtf8 (Closed)
Patch Set: Add isDeadCheck and isFlat tests Created 10 years, 8 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
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2709 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 if ( (length == -1) || (length > str->length() - start) ) 2720 if ( (length == -1) || (length > str->length() - start) )
2721 end = str->length() - start; 2721 end = str->length() - start;
2722 if (end < 0) return 0; 2722 if (end < 0) return 0;
2723 i::String::WriteToFlat(*str, buffer, start, end); 2723 i::String::WriteToFlat(*str, buffer, start, end);
2724 if (length == -1 || end < length) 2724 if (length == -1 || end < length)
2725 buffer[end] = '\0'; 2725 buffer[end] = '\0';
2726 return end; 2726 return end;
2727 } 2727 }
2728 2728
2729 2729
2730 void v8::String::Flatten() {
2731 if (IsDeadCheck("v8::String::Flatten()")) return;
2732 i::Handle<i::String> str = Utils::OpenHandle(this);
2733 i::FlattenString(str);
2734 }
2735
2736
2730 bool v8::String::IsExternal() const { 2737 bool v8::String::IsExternal() const {
2731 EnsureInitialized("v8::String::IsExternal()"); 2738 EnsureInitialized("v8::String::IsExternal()");
2732 i::Handle<i::String> str = Utils::OpenHandle(this); 2739 i::Handle<i::String> str = Utils::OpenHandle(this);
2733 return i::StringShape(*str).IsExternalTwoByte(); 2740 return i::StringShape(*str).IsExternalTwoByte();
2734 } 2741 }
2735 2742
2736 2743
2737 bool v8::String::IsExternalAscii() const { 2744 bool v8::String::IsExternalAscii() const {
2738 EnsureInitialized("v8::String::IsExternalAscii()"); 2745 EnsureInitialized("v8::String::IsExternalAscii()");
2739 i::Handle<i::String> str = Utils::OpenHandle(this); 2746 i::Handle<i::String> str = Utils::OpenHandle(this);
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
4073 4080
4074 4081
4075 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 4082 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
4076 HandleScopeImplementer* thread_local = 4083 HandleScopeImplementer* thread_local =
4077 reinterpret_cast<HandleScopeImplementer*>(storage); 4084 reinterpret_cast<HandleScopeImplementer*>(storage);
4078 thread_local->IterateThis(v); 4085 thread_local->IterateThis(v);
4079 return storage + ArchiveSpacePerThread(); 4086 return storage + ArchiveSpacePerThread();
4080 } 4087 }
4081 4088
4082 } } // namespace v8::internal 4089 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-strings.cc » ('j') | test/cctest/test-strings.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698