src: use DCHECK_* macros where possible
PR-URL: https://github.com/nodejs/node/pull/25207 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
e01999db14
commit
c2b4269b77
@ -198,9 +198,7 @@ class AliasedBuffer {
|
|||||||
* Set position index to given value.
|
* Set position index to given value.
|
||||||
*/
|
*/
|
||||||
inline void SetValue(const size_t index, NativeT value) {
|
inline void SetValue(const size_t index, NativeT value) {
|
||||||
#if defined(DEBUG) && DEBUG
|
DCHECK_LT(index, count_);
|
||||||
CHECK_LT(index, count_);
|
|
||||||
#endif
|
|
||||||
buffer_[index] = value;
|
buffer_[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,9 +206,7 @@ class AliasedBuffer {
|
|||||||
* Get value at position index
|
* Get value at position index
|
||||||
*/
|
*/
|
||||||
inline const NativeT GetValue(const size_t index) const {
|
inline const NativeT GetValue(const size_t index) const {
|
||||||
#if defined(DEBUG) && DEBUG
|
DCHECK_LT(index, count_);
|
||||||
CHECK_LT(index, count_);
|
|
||||||
#endif
|
|
||||||
return buffer_[index];
|
return buffer_[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,9 +229,9 @@ class AliasedBuffer {
|
|||||||
// Should only be used on an owning array, not one created as a sub array of
|
// Should only be used on an owning array, not one created as a sub array of
|
||||||
// an owning `AliasedBuffer`.
|
// an owning `AliasedBuffer`.
|
||||||
void reserve(size_t new_capacity) {
|
void reserve(size_t new_capacity) {
|
||||||
|
DCHECK_GE(new_capacity, count_);
|
||||||
|
DCHECK_EQ(byte_offset_, 0);
|
||||||
#if defined(DEBUG) && DEBUG
|
#if defined(DEBUG) && DEBUG
|
||||||
CHECK_GE(new_capacity, count_);
|
|
||||||
CHECK_EQ(byte_offset_, 0);
|
|
||||||
CHECK(free_buffer_);
|
CHECK(free_buffer_);
|
||||||
#endif
|
#endif
|
||||||
const v8::HandleScope handle_scope(isolate_);
|
const v8::HandleScope handle_scope(isolate_);
|
||||||
|
@ -115,8 +115,8 @@ BaseObject::MakeLazilyInitializedJSTemplate(Environment* env) {
|
|||||||
auto constructor = [](const v8::FunctionCallbackInfo<v8::Value>& args) {
|
auto constructor = [](const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
CHECK(args.IsConstructCall());
|
CHECK(args.IsConstructCall());
|
||||||
CHECK_GT(args.This()->InternalFieldCount(), 0);
|
|
||||||
#endif
|
#endif
|
||||||
|
DCHECK_GT(args.This()->InternalFieldCount(), 0);
|
||||||
args.This()->SetAlignedPointerInInternalField(0, nullptr);
|
args.This()->SetAlignedPointerInInternalField(0, nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,9 +68,7 @@ template <typename... Args>
|
|||||||
inline void FORCE_INLINE Debug(AsyncWrap* async_wrap,
|
inline void FORCE_INLINE Debug(AsyncWrap* async_wrap,
|
||||||
const char* format,
|
const char* format,
|
||||||
Args&&... args) {
|
Args&&... args) {
|
||||||
#ifdef DEBUG
|
DCHECK_NOT_NULL(async_wrap);
|
||||||
CHECK_NOT_NULL(async_wrap);
|
|
||||||
#endif
|
|
||||||
DebugCategory cat =
|
DebugCategory cat =
|
||||||
static_cast<DebugCategory>(async_wrap->provider_type());
|
static_cast<DebugCategory>(async_wrap->provider_type());
|
||||||
if (!UNLIKELY(async_wrap->env()->debug_enabled(cat)))
|
if (!UNLIKELY(async_wrap->env()->debug_enabled(cat)))
|
||||||
|
@ -123,11 +123,9 @@ MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
|
|||||||
body = !prepend.IsEmpty() ? prepend : String::Empty(isolate);
|
body = !prepend.IsEmpty() ? prepend : String::Empty(isolate);
|
||||||
prepend = Local<String>();
|
prepend = Local<String>();
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
|
||||||
// If not, that means is no character left to finish at this point.
|
// If not, that means is no character left to finish at this point.
|
||||||
CHECK_EQ(MissingBytes(), 0);
|
DCHECK_EQ(MissingBytes(), 0);
|
||||||
CHECK_EQ(BufferedBytes(), 0);
|
DCHECK_EQ(BufferedBytes(), 0);
|
||||||
#endif
|
|
||||||
|
|
||||||
// See whether there is a character that we may have to cut off and
|
// See whether there is a character that we may have to cut off and
|
||||||
// finish when receiving the next chunk.
|
// finish when receiving the next chunk.
|
||||||
@ -136,9 +134,7 @@ MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
|
|||||||
// This means we'll need to figure out where the character to which
|
// This means we'll need to figure out where the character to which
|
||||||
// the byte belongs begins.
|
// the byte belongs begins.
|
||||||
for (size_t i = nread - 1; ; --i) {
|
for (size_t i = nread - 1; ; --i) {
|
||||||
#ifdef DEBUG
|
DCHECK_LT(i, nread);
|
||||||
CHECK_LT(i, nread);
|
|
||||||
#endif
|
|
||||||
state_[kBufferedBytes]++;
|
state_[kBufferedBytes]++;
|
||||||
if ((data[i] & 0xC0) == 0x80) {
|
if ((data[i] & 0xC0) == 0x80) {
|
||||||
// This byte does not start a character (a "trailing" byte).
|
// This byte does not start a character (a "trailing" byte).
|
||||||
|
@ -37,9 +37,7 @@ class Vector {
|
|||||||
|
|
||||||
// Access individual vector elements - checks bounds in debug mode.
|
// Access individual vector elements - checks bounds in debug mode.
|
||||||
T& operator[](size_t index) const {
|
T& operator[](size_t index) const {
|
||||||
#ifdef DEBUG
|
DCHECK_LT(index, length_);
|
||||||
CHECK(index < length_);
|
|
||||||
#endif
|
|
||||||
return start_[is_forward_ ? index : (length_ - index - 1)];
|
return start_[is_forward_ ? index : (length_ - index - 1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user