From c742b72354a84958b6a061755249822eeef87d06 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 10 Jan 2018 11:46:09 -0800 Subject: Changes imported from Abseil "staging" branch: - f679f7de2957ac4dca0a862d04f1165d2f503525 Merge GitHub PR #78: Fix typo in thread_identity.h by Derek Mauro - 369cbefc9ebb8503e3c25b1516c856dab3bed7ac Minor refactor of operator-(uint128). by Alex Strelnikov - fba0f8c33b051d90936ad0fcaa4bea83f554bf8d Merge GitHub PR #75: Fix typo in per_thread_tls.h by Derek Mauro - 76d5d25a54ab93c1ea3bc74b5a28ba335b0f2bab Implement InlinedVector::shrink_to_fit() method. by Abseil Team GitOrigin-RevId: f679f7de2957ac4dca0a862d04f1165d2f503525 Change-Id: I03b39fdbd70c00a455d98d949d413dd7c8019578 --- absl/numeric/int128.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'absl/numeric') diff --git a/absl/numeric/int128.h b/absl/numeric/int128.h index f42a4aa..a204ac4 100644 --- a/absl/numeric/int128.h +++ b/absl/numeric/int128.h @@ -460,13 +460,10 @@ inline bool operator>=(uint128 lhs, uint128 rhs) { // Unary operators. inline uint128 operator-(uint128 val) { - const uint64_t hi_flip = ~Uint128High64(val); - const uint64_t lo_flip = ~Uint128Low64(val); - const uint64_t lo_add = lo_flip + 1; - if (lo_add < lo_flip) { - return MakeUint128(hi_flip + 1, lo_add); - } - return MakeUint128(hi_flip, lo_add); + uint64_t hi = ~Uint128High64(val); + uint64_t lo = ~Uint128Low64(val) + 1; + if (lo == 0) ++hi; // carry + return MakeUint128(hi, lo); } inline bool operator!(uint128 val) { -- cgit v1.2.3