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

Unified Diff: src/list-inl.h

Issue 113582: Introduced copy constructor for List<T, P> and changed constructor of Virtual... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/list.h ('k') | src/virtual-frame.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/list-inl.h
===================================================================
--- src/list-inl.h (revision 1993)
+++ src/list-inl.h (working copy)
@@ -34,6 +34,26 @@
template<typename T, class P>
+List<T, P>::List(const List<T, P>& other) {
+ ASSERT(other.capacity() >= 0);
+ capacity_ = other.capacity();
+ length_ = other.length();
+ if (capacity_ > 0) {
+ data_ = NewData(capacity_);
+ int copy_size = length_ * sizeof(T);
+ const int kMinMemCpySize = 64;
+ if (copy_size < kMinMemCpySize) {
+ for (int i = 0; i < length_; i++) data_[i] = other.data_[i];
+ } else {
+ memcpy(data_, other.data_, copy_size);
+ }
+ } else {
+ data_ = NULL;
+ }
+}
+
+
+template<typename T, class P>
void List<T, P>::Add(const T& element) {
if (length_ < capacity_) {
data_[length_++] = element;
« no previous file with comments | « src/list.h ('k') | src/virtual-frame.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698