summaryrefslogtreecommitdiff
path: root/absl/cleanup
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2021-02-03 10:18:15 -0800
committerGravatar Gennadiy Rozental <rogeeff@google.com>2021-02-03 16:30:41 -0500
commit9c6a50fdd80bb39fabd95faeda84f04062685ff3 (patch)
tree35e1acfc8db537ac89598c2d5c4590693a91de45 /absl/cleanup
parent58a9c6d53f93078101c2c0bd98d2951e74328a55 (diff)
Export of internal Abseil changes
-- 4ff721439234e91caf6f7b772e5f554e7dd423c8 by Benjamin Barenblat <bbaren@google.com>: Remove endian-sensitivity from hash slow path Prior to this commit, the Abseil hash fast path was endian-agnostic, but the slow path assumed a little-endian platform. Change the slow path to be endian-correct, ensuring that values produced by the fast and slow paths are equal even on big-endian systems. PiperOrigin-RevId: 355424258 -- 7f4fe1aa4de46ad0a2ef19fa9c061fc12a7391ed by Abseil Team <absl-team@google.com>: Directly store CordzInfo in the InlineData data contents of InlineRep This greatly reduces the cost of coping and moving cords. Especially the move constructor and move assignment are now back to lean loads and stores without needing any CordzInfo lookups for tracked cords. PiperOrigin-RevId: 355409161 -- 3ca4ca84ed6d98f1e383ffd8d12c28876e905bb3 by Abseil Team <absl-team@google.com>: Add #include <unordered_map> PiperOrigin-RevId: 355386114 -- 30b0ffad0621971b3135148fcc9e183b0dd2a6bb by Abseil Team <absl-team@google.com>: Optimize Cord copy constructor This change avoids double stores of the Cord copy constructor from the zero init of the InlineData / InlineRep contents followed by the assignment and inlines the copy constructor. PiperOrigin-RevId: 355287939 -- 0c043fa7b6e41ca7cefc5edc1e17ad46223e4e77 by CJ Johnson <johnsoncj@google.com>: Now that the absl::Cleanup example returns absl::Status, since we decided on absl::FailedPreconditionError, the precondition should be a positive statement and then the check should be failure to adhere to that positive statement PiperOrigin-RevId: 355216923 -- 9ed922ca5d28fe8790ec6bc0837cf39fbcc92896 by Gennadiy Rozental <rogeeff@google.com>: Do not set mvsc linker flags for clang-cl (fixes #874) Import of https://github.com/abseil/abseil-cpp/pull/891 PiperOrigin-RevId: 355199380 GitOrigin-RevId: 4ff721439234e91caf6f7b772e5f554e7dd423c8 Change-Id: I3d9d2383549720d7a91f9108dfcd979ad6632fce
Diffstat (limited to 'absl/cleanup')
-rw-r--r--absl/cleanup/cleanup.h4
-rw-r--r--absl/cleanup/internal/cleanup.h14
2 files changed, 10 insertions, 8 deletions
diff --git a/absl/cleanup/cleanup.h b/absl/cleanup/cleanup.h
index 5a4bc546..8ebf1e9b 100644
--- a/absl/cleanup/cleanup.h
+++ b/absl/cleanup/cleanup.h
@@ -41,7 +41,7 @@
//
// Data data;
// while (ReadData(source_file, &data)) {
-// if (data.IsBad()) {
+// if (!data.IsGood()) {
// absl::Status result = absl::FailedPreconditionError("Read bad data");
// return result; // Both cleanups execute
// }
@@ -87,7 +87,7 @@ class ABSL_MUST_USE_RESULT Cleanup {
public:
Cleanup(Callback callback) // NOLINT
- : storage_(std::move(callback), /*engaged=*/true) {}
+ : storage_(std::move(callback), /* is_callback_engaged = */ true) {}
Cleanup(Cleanup&& other) = default;
diff --git a/absl/cleanup/internal/cleanup.h b/absl/cleanup/internal/cleanup.h
index b68e3dd3..b4c40737 100644
--- a/absl/cleanup/internal/cleanup.h
+++ b/absl/cleanup/internal/cleanup.h
@@ -45,12 +45,14 @@ class Storage {
public:
Storage() = delete;
- Storage(Callback callback, bool engaged)
- : callback_(std::move(callback)), engaged_(engaged) {}
+ Storage(Callback callback, bool is_callback_engaged)
+ : callback_(std::move(callback)),
+ is_callback_engaged_(is_callback_engaged) {}
Storage(Storage&& other)
: callback_(std::move(other.callback_)),
- engaged_(absl::exchange(other.engaged_, false)) {}
+ is_callback_engaged_(
+ absl::exchange(other.is_callback_engaged_, false)) {}
Storage(const Storage& other) = delete;
@@ -58,9 +60,9 @@ class Storage {
Storage& operator=(const Storage& other) = delete;
- bool IsCallbackEngaged() const { return engaged_; }
+ bool IsCallbackEngaged() const { return is_callback_engaged_; }
- void DisengageCallback() { engaged_ = false; }
+ void DisengageCallback() { is_callback_engaged_ = false; }
void InvokeCallback() ABSL_NO_THREAD_SAFETY_ANALYSIS {
std::move(callback_)();
@@ -68,7 +70,7 @@ class Storage {
private:
Callback callback_;
- bool engaged_;
+ bool is_callback_engaged_;
};
} // namespace cleanup_internal