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

Side by Side Diff: src/string-stream.cc

Issue 13932006: Replace OS::MemCopy with OS::MemMove (just as fast but more flexible). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/serialize.h ('k') | src/unicode-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1, 247 void StringStream::Add(const char* format, FmtElm arg0, FmtElm arg1,
248 FmtElm arg2, FmtElm arg3) { 248 FmtElm arg2, FmtElm arg3) {
249 const char argc = 4; 249 const char argc = 4;
250 FmtElm argv[argc] = { arg0, arg1, arg2, arg3 }; 250 FmtElm argv[argc] = { arg0, arg1, arg2, arg3 };
251 Add(CStrVector(format), Vector<FmtElm>(argv, argc)); 251 Add(CStrVector(format), Vector<FmtElm>(argv, argc));
252 } 252 }
253 253
254 254
255 SmartArrayPointer<const char> StringStream::ToCString() const { 255 SmartArrayPointer<const char> StringStream::ToCString() const {
256 char* str = NewArray<char>(length_ + 1); 256 char* str = NewArray<char>(length_ + 1);
257 memcpy(str, buffer_, length_); 257 OS::MemCopy(str, buffer_, length_);
258 str[length_] = '\0'; 258 str[length_] = '\0';
259 return SmartArrayPointer<const char>(str); 259 return SmartArrayPointer<const char>(str);
260 } 260 }
261 261
262 262
263 void StringStream::Log() { 263 void StringStream::Log() {
264 LOG(ISOLATE, StringEvent("StackDump", buffer_)); 264 LOG(ISOLATE, StringEvent("StackDump", buffer_));
265 } 265 }
266 266
267 267
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 char* HeapStringAllocator::grow(unsigned* bytes) { 568 char* HeapStringAllocator::grow(unsigned* bytes) {
569 unsigned new_bytes = *bytes * 2; 569 unsigned new_bytes = *bytes * 2;
570 // Check for overflow. 570 // Check for overflow.
571 if (new_bytes <= *bytes) { 571 if (new_bytes <= *bytes) {
572 return space_; 572 return space_;
573 } 573 }
574 char* new_space = NewArray<char>(new_bytes); 574 char* new_space = NewArray<char>(new_bytes);
575 if (new_space == NULL) { 575 if (new_space == NULL) {
576 return space_; 576 return space_;
577 } 577 }
578 memcpy(new_space, space_, *bytes); 578 OS::MemCopy(new_space, space_, *bytes);
579 *bytes = new_bytes; 579 *bytes = new_bytes;
580 DeleteArray(space_); 580 DeleteArray(space_);
581 space_ = new_space; 581 space_ = new_space;
582 return new_space; 582 return new_space;
583 } 583 }
584 584
585 585
586 // Only grow once to the maximum allowable size. 586 // Only grow once to the maximum allowable size.
587 char* NoAllocationStringAllocator::grow(unsigned* bytes) { 587 char* NoAllocationStringAllocator::grow(unsigned* bytes) {
588 ASSERT(size_ >= *bytes); 588 ASSERT(size_ >= *bytes);
589 *bytes = size_; 589 *bytes = size_;
590 return space_; 590 return space_;
591 } 591 }
592 592
593 593
594 } } // namespace v8::internal 594 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/serialize.h ('k') | src/unicode-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698