| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // An arena that consists of a single inlined block of |ArenaSize|. Useful to | 5 // An arena that consists of a single inlined block of |ArenaSize|. Useful to |
| 6 // avoid repeated calls to malloc/new and to improve memory locality. DCHECK's | 6 // avoid repeated calls to malloc/new and to improve memory locality. DCHECK's |
| 7 // if an allocation out of the arena ever fails in debug builds; falls back to | 7 // if an allocation out of the arena ever fails in debug builds; falls back to |
| 8 // heap allocation in release builds. | 8 // heap allocation in release builds. |
| 9 | 9 |
| 10 #ifndef NET_QUIC_QUIC_ONE_BLOCK_ARENA_H_ | 10 #ifndef NET_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ |
| 11 #define NET_QUIC_QUIC_ONE_BLOCK_ARENA_H_ | 11 #define NET_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ |
| 12 | 12 |
| 13 #include "net/quic/core/quic_arena_scoped_ptr.h" | 13 #include "net/quic/core/quic_arena_scoped_ptr.h" |
| 14 #include "net/quic/core/quic_flags.h" | 14 #include "net/quic/core/quic_flags.h" |
| 15 #include "net/quic/core/quic_utils.h" | 15 #include "net/quic/core/quic_utils.h" |
| 16 | 16 |
| 17 #define PREDICT_FALSE(x) x | 17 #define PREDICT_FALSE(x) x |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 | 20 |
| 21 template <uint32_t ArenaSize> | 21 template <uint32_t ArenaSize> |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 void* buf = &storage_[offset_]; | 68 void* buf = &storage_[offset_]; |
| 69 new (buf) T(std::forward<Args>(args)...); | 69 new (buf) T(std::forward<Args>(args)...); |
| 70 offset_ += AlignedSize<T>(); | 70 offset_ += AlignedSize<T>(); |
| 71 return QuicArenaScopedPtr<T>(buf, | 71 return QuicArenaScopedPtr<T>(buf, |
| 72 QuicArenaScopedPtr<T>::ConstructFrom::kArena); | 72 QuicArenaScopedPtr<T>::ConstructFrom::kArena); |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace net | 75 } // namespace net |
| 76 | 76 |
| 77 #endif // NET_QUIC_QUIC_ONE_BLOCK_ARENA_H_ | 77 #endif // NET_QUIC_CORE_QUIC_ONE_BLOCK_ARENA_H_ |
| OLD | NEW |