mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
Add ABSL_HARDENING_ASSERTs to CordBuffer::SetLength() and
CordBuffer::IncreaseLengthBy() PiperOrigin-RevId: 453243686 Change-Id: If109da6be651006d4d9820bcc10eddfb56deaea2
This commit is contained in:
committed by
Copybara-Service
parent
800a88de73
commit
91b8bfab44
@@ -32,6 +32,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "absl/base/config.h"
|
||||
#include "absl/base/macros.h"
|
||||
#include "absl/numeric/bits.h"
|
||||
#include "absl/strings/internal/cord_internal.h"
|
||||
#include "absl/strings/internal/cord_rep_flat.h"
|
||||
@@ -548,7 +549,7 @@ inline size_t CordBuffer::length() const {
|
||||
}
|
||||
|
||||
inline void CordBuffer::SetLength(size_t length) {
|
||||
assert(length <= capacity());
|
||||
ABSL_HARDENING_ASSERT(length <= capacity());
|
||||
if (rep_.is_short()) {
|
||||
rep_.set_short_length(length);
|
||||
} else {
|
||||
@@ -557,7 +558,7 @@ inline void CordBuffer::SetLength(size_t length) {
|
||||
}
|
||||
|
||||
inline void CordBuffer::IncreaseLengthBy(size_t n) {
|
||||
assert(n <= capacity() && length() + n <= capacity());
|
||||
ABSL_HARDENING_ASSERT(n <= capacity() && length() + n <= capacity());
|
||||
if (rep_.is_short()) {
|
||||
rep_.add_short_length(n);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user