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

Side by Side Diff: mojo/public/cpp/bindings/lib/array_internal.h

Issue 1535943002: Convert Pass()→std::move() in //mojo/public/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove self-move checks to avoid triggering clang warning. Created 5 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_
7 7
8 #include <new> 8 #include <new>
9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "mojo/public/c/system/macros.h" 12 #include "mojo/public/c/system/macros.h"
12 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 13 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
13 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" 14 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
14 #include "mojo/public/cpp/bindings/lib/bounds_checker.h" 15 #include "mojo/public/cpp/bindings/lib/bounds_checker.h"
15 #include "mojo/public/cpp/bindings/lib/buffer.h" 16 #include "mojo/public/cpp/bindings/lib/buffer.h"
16 #include "mojo/public/cpp/bindings/lib/map_data_internal.h" 17 #include "mojo/public/cpp/bindings/lib/map_data_internal.h"
17 #include "mojo/public/cpp/bindings/lib/template_util.h" 18 #include "mojo/public/cpp/bindings/lib/template_util.h"
18 #include "mojo/public/cpp/bindings/lib/validate_params.h" 19 #include "mojo/public/cpp/bindings/lib/validate_params.h"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 size_t old_size = vec->size(); 496 size_t old_size = vec->size();
496 for (size_t i = size; i < old_size; i++) 497 for (size_t i = size; i < old_size; i++)
497 reinterpret_cast<T*>(vec->at(i).buf)->~T(); 498 reinterpret_cast<T*>(vec->at(i).buf)->~T();
498 ResizeStorage(vec, size); 499 ResizeStorage(vec, size);
499 for (size_t i = old_size; i < vec->size(); i++) 500 for (size_t i = old_size; i < vec->size(); i++)
500 new (vec->at(i).buf) T(); 501 new (vec->at(i).buf) T();
501 } 502 }
502 static inline void PushBack(std::vector<StorageType>* vec, RefType value) { 503 static inline void PushBack(std::vector<StorageType>* vec, RefType value) {
503 size_t old_size = vec->size(); 504 size_t old_size = vec->size();
504 ResizeStorage(vec, old_size + 1); 505 ResizeStorage(vec, old_size + 1);
505 new (vec->at(old_size).buf) T(value.Pass()); 506 new (vec->at(old_size).buf) T(std::move(value));
506 } 507 }
507 static inline void ResizeStorage(std::vector<StorageType>* vec, size_t size) { 508 static inline void ResizeStorage(std::vector<StorageType>* vec, size_t size) {
508 if (size <= vec->capacity()) { 509 if (size <= vec->capacity()) {
509 vec->resize(size); 510 vec->resize(size);
510 return; 511 return;
511 } 512 }
512 std::vector<StorageType> new_storage(size); 513 std::vector<StorageType> new_storage(size);
513 for (size_t i = 0; i < vec->size(); i++) 514 for (size_t i = 0; i < vec->size(); i++)
514 new (new_storage.at(i).buf) T(at(vec, i).Pass()); 515 new (new_storage.at(i).buf) T(std::move(at(vec, i)));
515 vec->swap(new_storage); 516 vec->swap(new_storage);
516 Finalize(&new_storage); 517 Finalize(&new_storage);
517 } 518 }
518 static inline void Clone(const std::vector<StorageType>& src_vec, 519 static inline void Clone(const std::vector<StorageType>& src_vec,
519 std::vector<StorageType>* dest_vec) { 520 std::vector<StorageType>* dest_vec) {
520 Resize(dest_vec, src_vec.size()); 521 Resize(dest_vec, src_vec.size());
521 for (size_t i = 0; i < src_vec.size(); ++i) 522 for (size_t i = 0; i < src_vec.size(); ++i)
522 at(dest_vec, i) = at(&src_vec, i).Clone(); 523 at(dest_vec, i) = at(&src_vec, i).Clone();
523 } 524 }
524 }; 525 };
525 526
526 template <> 527 template <>
527 struct WrapperTraits<String, false> { 528 struct WrapperTraits<String, false> {
528 typedef String_Data* DataType; 529 typedef String_Data* DataType;
529 }; 530 };
530 531
531 } // namespace internal 532 } // namespace internal
532 } // namespace mojo 533 } // namespace mojo
533 534
534 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ 535 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698