| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_WTF_CLONE_EQUALS_UTIL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_WTF_CLONE_EQUALS_UTIL_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_WTF_CLONE_EQUALS_UTIL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_WTF_CLONE_EQUALS_UTIL_H_ |
| 7 | 7 |
| 8 #include <type_traits> | 8 #include <type_traits> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/lib/clone_equals_util.h" | 10 #include "mojo/public/cpp/bindings/lib/clone_equals_util.h" |
| 11 #include "third_party/WebKit/Source/wtf/HashMap.h" | 11 #include "third_party/WebKit/Source/wtf/HashMap.h" |
| 12 #include "third_party/WebKit/Source/wtf/Optional.h" | 12 #include "third_party/WebKit/Source/wtf/Optional.h" |
| 13 #include "third_party/WebKit/Source/wtf/Vector.h" | 13 #include "third_party/WebKit/Source/wtf/Vector.h" |
| 14 #include "third_party/WebKit/Source/wtf/text/WTFString.h" | 14 #include "third_party/WebKit/Source/wtf/text/WTFString.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 namespace internal { | 17 namespace internal { |
| 18 | 18 |
| 19 template <typename T> | 19 template <typename T> |
| 20 struct CloneTraits<WTF::Vector<T>, false> { | 20 struct CloneTraits<WTF::Vector<T>, false> { |
| 21 static WTF::Vector<T> Clone(const WTF::Vector<T>& input) { | 21 static WTF::Vector<T> Clone(const WTF::Vector<T>& input) { |
| 22 WTF::Vector<T> result; | 22 WTF::Vector<T> result; |
| 23 result.reserveCapacity(input.size()); | 23 result.reserveCapacity(input.size()); |
| 24 for (const auto& element : input) | 24 for (const auto& element : input) |
| 25 result.append(internal::Clone(element)); | 25 result.push_back(internal::Clone(element)); |
| 26 | 26 |
| 27 return result; | 27 return result; |
| 28 } | 28 } |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 template <typename K, typename V> | 31 template <typename K, typename V> |
| 32 struct CloneTraits<WTF::HashMap<K, V>, false> { | 32 struct CloneTraits<WTF::HashMap<K, V>, false> { |
| 33 static WTF::HashMap<K, V> Clone(const WTF::HashMap<K, V>& input) { | 33 static WTF::HashMap<K, V> Clone(const WTF::HashMap<K, V>& input) { |
| 34 WTF::HashMap<K, V> result; | 34 WTF::HashMap<K, V> result; |
| 35 auto input_end = input.end(); | 35 auto input_end = input.end(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 return false; | 67 return false; |
| 68 } | 68 } |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace internal | 73 } // namespace internal |
| 74 } // namespace mojo | 74 } // namespace mojo |
| 75 | 75 |
| 76 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_WTF_CLONE_EQUALS_UTIL_H_ | 76 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_WTF_CLONE_EQUALS_UTIL_H_ |
| OLD | NEW |