Export of internal Abseil changes.
-- 298d93fcb860116111611a8ab0662b409734227a by Alex Strelnikov <strel@google.com>: Release ascii_benchmark. PiperOrigin-RevId: 205275981 -- 73a01469e5862eefbe5ef9d434f45b7073476272 by Abseil Team <absl-team@google.com>: Internal cleanup PiperOrigin-RevId: 205236717 -- 53d6338bf49dab95bd0fbb5bbcd56970c6b868c2 by Abseil Team <absl-team@google.com>: Removes InlinedVector's dependency on bitwise operators for size_type PiperOrigin-RevId: 205236134 GitOrigin-RevId: 298d93fcb860116111611a8ab0662b409734227a Change-Id: I754f5eea889567add2dbbdea358a533f54a912dd
This commit is contained in:
parent
2c5af55ed3
commit
7aa411ceaf
3 changed files with 141 additions and 5 deletions
|
@ -626,14 +626,18 @@ class InlinedVector {
|
|||
// It holds whether the vector is allocated or not in the lowest bit.
|
||||
// The size is held in the high bits:
|
||||
// size_ = (size << 1) | is_allocated;
|
||||
//
|
||||
// Maintainer's Note: size_type is user defined. The contract is limited to
|
||||
// arithmetic operators to avoid depending on compliant overloaded bitwise
|
||||
// operators.
|
||||
class Tag {
|
||||
public:
|
||||
Tag() : size_(0) {}
|
||||
size_type size() const { return size_ >> 1; }
|
||||
void add_size(size_type n) { size_ += n << 1; }
|
||||
void set_inline_size(size_type n) { size_ = n << 1; }
|
||||
void set_allocated_size(size_type n) { size_ = (n << 1) | 1; }
|
||||
bool allocated() const { return size_ & 1; }
|
||||
size_type size() const { return size_ / 2; }
|
||||
void add_size(size_type n) { size_ += n * 2; }
|
||||
void set_inline_size(size_type n) { size_ = n * 2; }
|
||||
void set_allocated_size(size_type n) { size_ = (n * 2) + 1; }
|
||||
bool allocated() const { return size_ % 2; }
|
||||
|
||||
private:
|
||||
size_type size_;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue