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

Side by Side Diff: src/api.cc

Issue 255004: Do not flatten the string, but just write it out.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2428 matching lines...) Expand 10 before | Expand all | Expand 10 after
2439 return i; 2439 return i;
2440 } 2440 }
2441 2441
2442 2442
2443 int String::Write(uint16_t* buffer, int start, int length) const { 2443 int String::Write(uint16_t* buffer, int start, int length) const {
2444 if (IsDeadCheck("v8::String::Write()")) return 0; 2444 if (IsDeadCheck("v8::String::Write()")) return 0;
2445 LOG_API("String::Write"); 2445 LOG_API("String::Write");
2446 ENTER_V8; 2446 ENTER_V8;
2447 ASSERT(start >= 0 && length >= -1); 2447 ASSERT(start >= 0 && length >= -1);
2448 i::Handle<i::String> str = Utils::OpenHandle(this); 2448 i::Handle<i::String> str = Utils::OpenHandle(this);
2449 // Flatten the string for efficiency. This applies whether we are
2450 // using StringInputBuffer or Get(i) to access the characters.
2451 str->TryFlattenIfNotFlat();
2452 int end = length; 2449 int end = length;
2453 if ( (length == -1) || (length > str->length() - start) ) 2450 if ( (length == -1) || (length > str->length() - start) )
2454 end = str->length() - start; 2451 end = str->length() - start;
2455 if (end < 0) return 0; 2452 if (end < 0) return 0;
2456 write_input_buffer.Reset(start, *str); 2453 i::String::WriteToFlat(*str, buffer, start, end);
2457 int i; 2454 if (length == -1 || end < length)
2458 for (i = 0; i < end; i++) 2455 buffer[end] = '\0';
2459 buffer[i] = write_input_buffer.GetNext(); 2456 return end;
2460 if (length == -1 || i < length)
2461 buffer[i] = '\0';
2462 return i;
2463 } 2457 }
2464 2458
2465 2459
2466 bool v8::String::IsExternal() const { 2460 bool v8::String::IsExternal() const {
2467 EnsureInitialized("v8::String::IsExternal()"); 2461 EnsureInitialized("v8::String::IsExternal()");
2468 i::Handle<i::String> str = Utils::OpenHandle(this); 2462 i::Handle<i::String> str = Utils::OpenHandle(this);
2469 return i::StringShape(*str).IsExternalTwoByte(); 2463 return i::StringShape(*str).IsExternalTwoByte();
2470 } 2464 }
2471 2465
2472 2466
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
3766 3760
3767 3761
3768 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 3762 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
3769 HandleScopeImplementer* thread_local = 3763 HandleScopeImplementer* thread_local =
3770 reinterpret_cast<HandleScopeImplementer*>(storage); 3764 reinterpret_cast<HandleScopeImplementer*>(storage);
3771 thread_local->IterateThis(v); 3765 thread_local->IterateThis(v);
3772 return storage + ArchiveSpacePerThread(); 3766 return storage + ArchiveSpacePerThread();
3773 } 3767 }
3774 3768
3775 } } // namespace v8::internal 3769 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698