about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--absl/container/inlined_vector.h65
-rw-r--r--absl/time/internal/cctz/src/time_zone_format.cc2
-rw-r--r--absl/time/internal/cctz/src/time_zone_info.cc4
-rw-r--r--absl/time/internal/cctz/src/time_zone_libc.cc8
4 files changed, 38 insertions, 41 deletions
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index 6c67862e2df1..e0f1714cc866 100644
--- a/absl/container/inlined_vector.h
+++ b/absl/container/inlined_vector.h
@@ -67,7 +67,7 @@ namespace absl {
 template <typename T, size_t N, typename A = std::allocator<T>>
 class InlinedVector {
   static_assert(N > 0, "InlinedVector requires inline capacity greater than 0");
-  constexpr static typename A::size_type inlined_capacity() {
+  constexpr static typename A::size_type GetInlinedCapacity() {
     return static_cast<typename A::size_type>(N);
   }
 
@@ -275,12 +275,12 @@ class InlinedVector {
   // Returns the number of elements that can be stored in the inlined vector
   // without requiring a reallocation of underlying memory.
   //
-  // NOTE: For most inlined vectors, `capacity()` should equal
-  // `inlined_capacity()`. For inlined vectors which exceed this capacity, they
+  // NOTE: For most inlined vectors, `capacity()` should equal the template
+  // parameter `N`. For inlined vectors which exceed this capacity, they
   // will no longer be inlined and `capacity()` will equal its capacity on the
   // allocated heap.
   size_type capacity() const noexcept {
-    return allocated() ? allocation().capacity() : inlined_capacity();
+    return allocated() ? allocation().capacity() : GetInlinedCapacity();
   }
 
   // `InlinedVector::data()`
@@ -667,12 +667,9 @@ class InlinedVector {
   template <typename... Args>
   reference emplace_back(Args&&... args) {
     size_type s = size();
-    assert(s <= capacity());
     if (ABSL_PREDICT_FALSE(s == capacity())) {
       return GrowAndEmplaceBack(std::forward<Args>(args)...);
     }
-    assert(s < capacity());
-
     pointer space;
     if (allocated()) {
       tag().set_allocated_size(s + 1);
@@ -790,19 +787,19 @@ class InlinedVector {
   // `InlinedVector::shrink_to_fit()`
   //
   // Reduces memory usage by freeing unused memory. After this call, calls to
-  // `capacity()` will be equal to `(std::max)(inlined_capacity(), size())`.
+  // `capacity()` will be equal to `(std::max)(GetInlinedCapacity(), size())`.
   //
-  // If `size() <= inlined_capacity()` and the elements are currently stored on
-  // the heap, they will be moved to the inlined storage and the heap memory
+  // If `size() <= GetInlinedCapacity()` and the elements are currently stored
+  // on the heap, they will be moved to the inlined storage and the heap memory
   // will be deallocated.
   //
-  // If `size() > inlined_capacity()` and `size() < capacity()` the elements
+  // If `size() > GetInlinedCapacity()` and `size() < capacity()` the elements
   // will be moved to a smaller heap allocation.
   void shrink_to_fit() {
     const auto s = size();
     if (ABSL_PREDICT_FALSE(!allocated() || s == capacity())) return;
 
-    if (s <= inlined_capacity()) {
+    if (s <= GetInlinedCapacity()) {
       // Move the elements to the inlined storage.
       // We have to do this using a temporary, because `inlined_storage` and
       // `allocation_storage` are in a union field.
@@ -833,7 +830,7 @@ class InlinedVector {
 
  private:
   template <typename H, typename TheT, size_t TheN, typename TheA>
-  friend H AbslHashValue(H, const InlinedVector<TheT, TheN, TheA>& vector);
+  friend auto AbslHashValue(H h, const InlinedVector<TheT, TheN, TheA>& v) -> H;
 
   // Holds whether the vector is allocated or not in the lowest bit and the size
   // in the high bits:
@@ -984,7 +981,7 @@ class InlinedVector {
     const size_type s = size();
     assert(s <= capacity());
 
-    size_type target = (std::max)(inlined_capacity(), s + delta);
+    size_type target = (std::max)(GetInlinedCapacity(), s + delta);
 
     // Compute new capacity by repeatedly doubling current capacity
     // TODO(psrc): Check and avoid overflow?
@@ -1087,7 +1084,7 @@ class InlinedVector {
   }
 
   void InitAssign(size_type n) {
-    if (n > inlined_capacity()) {
+    if (n > GetInlinedCapacity()) {
       Allocation new_allocation(allocator(), n);
       init_allocation(new_allocation);
       UninitializedFill(allocated_space(), allocated_space() + n);
@@ -1099,7 +1096,7 @@ class InlinedVector {
   }
 
   void InitAssign(size_type n, const_reference v) {
-    if (n > inlined_capacity()) {
+    if (n > GetInlinedCapacity()) {
       Allocation new_allocation(allocator(), n);
       init_allocation(new_allocation);
       UninitializedFill(allocated_space(), allocated_space() + n, v);
@@ -1323,8 +1320,8 @@ class InlinedVector {
 // Swaps the contents of two inlined vectors. This convenience function
 // simply calls `InlinedVector::swap()`.
 template <typename T, size_t N, typename A>
-void swap(InlinedVector<T, N, A>& a,
-          InlinedVector<T, N, A>& b) noexcept(noexcept(a.swap(b))) {
+auto swap(InlinedVector<T, N, A>& a,
+          InlinedVector<T, N, A>& b) noexcept(noexcept(a.swap(b))) -> void {
   a.swap(b);
 }
 
@@ -1332,8 +1329,8 @@ void swap(InlinedVector<T, N, A>& a,
 //
 // Tests the equivalency of the contents of two inlined vectors.
 template <typename T, size_t N, typename A>
-bool operator==(const InlinedVector<T, N, A>& a,
-                const InlinedVector<T, N, A>& b) {
+auto operator==(const InlinedVector<T, N, A>& a,
+                const InlinedVector<T, N, A>& b) -> bool {
   return absl::equal(a.begin(), a.end(), b.begin(), b.end());
 }
 
@@ -1341,8 +1338,8 @@ bool operator==(const InlinedVector<T, N, A>& a,
 //
 // Tests the inequality of the contents of two inlined vectors.
 template <typename T, size_t N, typename A>
-bool operator!=(const InlinedVector<T, N, A>& a,
-                const InlinedVector<T, N, A>& b) {
+auto operator!=(const InlinedVector<T, N, A>& a,
+                const InlinedVector<T, N, A>& b) -> bool {
   return !(a == b);
 }
 
@@ -1351,8 +1348,8 @@ bool operator!=(const InlinedVector<T, N, A>& a,
 // Tests whether the contents of one inlined vector are less than the contents
 // of another through a lexicographical comparison operation.
 template <typename T, size_t N, typename A>
-bool operator<(const InlinedVector<T, N, A>& a,
-               const InlinedVector<T, N, A>& b) {
+auto operator<(const InlinedVector<T, N, A>& a, const InlinedVector<T, N, A>& b)
+    -> bool {
   return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end());
 }
 
@@ -1361,8 +1358,8 @@ bool operator<(const InlinedVector<T, N, A>& a,
 // Tests whether the contents of one inlined vector are greater than the
 // contents of another through a lexicographical comparison operation.
 template <typename T, size_t N, typename A>
-bool operator>(const InlinedVector<T, N, A>& a,
-               const InlinedVector<T, N, A>& b) {
+auto operator>(const InlinedVector<T, N, A>& a, const InlinedVector<T, N, A>& b)
+    -> bool {
   return b < a;
 }
 
@@ -1371,8 +1368,8 @@ bool operator>(const InlinedVector<T, N, A>& a,
 // Tests whether the contents of one inlined vector are less than or equal to
 // the contents of another through a lexicographical comparison operation.
 template <typename T, size_t N, typename A>
-bool operator<=(const InlinedVector<T, N, A>& a,
-                const InlinedVector<T, N, A>& b) {
+auto operator<=(const InlinedVector<T, N, A>& a,
+                const InlinedVector<T, N, A>& b) -> bool {
   return !(b < a);
 }
 
@@ -1381,8 +1378,8 @@ bool operator<=(const InlinedVector<T, N, A>& a,
 // Tests whether the contents of one inlined vector are greater than or equal to
 // the contents of another through a lexicographical comparison operation.
 template <typename T, size_t N, typename A>
-bool operator>=(const InlinedVector<T, N, A>& a,
-                const InlinedVector<T, N, A>& b) {
+auto operator>=(const InlinedVector<T, N, A>& a,
+                const InlinedVector<T, N, A>& b) -> bool {
   return !(a < b);
 }
 
@@ -1391,10 +1388,10 @@ bool operator>=(const InlinedVector<T, N, A>& a,
 // Provides `absl::Hash` support for inlined vectors. You do not normally call
 // this function directly.
 template <typename H, typename TheT, size_t TheN, typename TheA>
-H AbslHashValue(H hash, const InlinedVector<TheT, TheN, TheA>& vector) {
-  auto p = vector.data();
-  auto n = vector.size();
-  return H::combine(H::combine_contiguous(std::move(hash), p, n), n);
+auto AbslHashValue(H h, const InlinedVector<TheT, TheN, TheA>& v) -> H {
+  auto p = v.data();
+  auto n = v.size();
+  return H::combine(H::combine_contiguous(std::move(h), p, n), n);
 }
 
 // -----------------------------------------------------------------------------
diff --git a/absl/time/internal/cctz/src/time_zone_format.cc b/absl/time/internal/cctz/src/time_zone_format.cc
index aad52c2719cc..a5c72df8c154 100644
--- a/absl/time/internal/cctz/src/time_zone_format.cc
+++ b/absl/time/internal/cctz/src/time_zone_format.cc
@@ -13,7 +13,7 @@
 //   limitations under the License.
 
 #if !defined(HAS_STRPTIME)
-# if !defined(_MSC_VER)
+# if !defined(_MSC_VER) && !defined(__MINGW32__)
 #  define HAS_STRPTIME 1  // assume everyone has strptime() except windows
 # endif
 #endif
diff --git a/absl/time/internal/cctz/src/time_zone_info.cc b/absl/time/internal/cctz/src/time_zone_info.cc
index 2cb358d048e2..6aa80ff638d3 100644
--- a/absl/time/internal/cctz/src/time_zone_info.cc
+++ b/absl/time/internal/cctz/src/time_zone_info.cc
@@ -921,7 +921,7 @@ bool TimeZoneInfo::NextTransition(const time_point<seconds>& tp,
     ++begin;
   }
   std::int_fast64_t unix_time = ToUnixSeconds(tp);
-  const Transition target = { unix_time };
+  const Transition target = {unix_time, 0, civil_second(), civil_second()};
   const Transition* tr = std::upper_bound(begin, end, target,
                                           Transition::ByUnixTime());
   for (; tr != end; ++tr) {  // skip no-op transitions
@@ -956,7 +956,7 @@ bool TimeZoneInfo::PrevTransition(const time_point<seconds>& tp,
     }
     unix_time += 1;  // ceils
   }
-  const Transition target = { unix_time };
+  const Transition target = {unix_time, 0, civil_second(), civil_second()};
   const Transition* tr = std::lower_bound(begin, end, target,
                                           Transition::ByUnixTime());
   for (; tr != begin; --tr) {  // skip no-op transitions
diff --git a/absl/time/internal/cctz/src/time_zone_libc.cc b/absl/time/internal/cctz/src/time_zone_libc.cc
index 6db519e165cf..28291708474c 100644
--- a/absl/time/internal/cctz/src/time_zone_libc.cc
+++ b/absl/time/internal/cctz/src/time_zone_libc.cc
@@ -267,13 +267,13 @@ time_zone::civil_lookup TimeZoneLibC::MakeTime(const civil_second& cs) const {
   return {time_zone::civil_lookup::UNIQUE, tp, tp, tp};
 }
 
-bool TimeZoneLibC::NextTransition(const time_point<seconds>& tp,
-                                  time_zone::civil_transition* trans) const {
+bool TimeZoneLibC::NextTransition(const time_point<seconds>&,
+                                  time_zone::civil_transition*) const {
   return false;
 }
 
-bool TimeZoneLibC::PrevTransition(const time_point<seconds>& tp,
-                                  time_zone::civil_transition* trans) const {
+bool TimeZoneLibC::PrevTransition(const time_point<seconds>&,
+                                  time_zone::civil_transition*) const {
   return false;
 }