summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2018-12-24 12:10:35 -0500
committercjihrig <cjihrig@gmail.com>2018-12-26 12:25:19 -0500
commitc2b4269b77822aee6d07ae427a3341abdbaa8c3f (patch)
treebdd52c57636e5d5d5fa9836599886551c267a947
parente01999db14034cb56625f40493d47b339da99048 (diff)
downloadandroid-node-v8-c2b4269b77822aee6d07ae427a3341abdbaa8c3f.tar.gz
android-node-v8-c2b4269b77822aee6d07ae427a3341abdbaa8c3f.tar.bz2
android-node-v8-c2b4269b77822aee6d07ae427a3341abdbaa8c3f.zip
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>
-rw-r--r--src/aliased_buffer.h12
-rw-r--r--src/base_object-inl.h2
-rw-r--r--src/debug_utils.h4
-rw-r--r--src/string_decoder.cc10
-rw-r--r--src/string_search.h4
5 files changed, 10 insertions, 22 deletions
diff --git a/src/aliased_buffer.h b/src/aliased_buffer.h
index fa610a9774..0bae974af7 100644
--- a/src/aliased_buffer.h
+++ b/src/aliased_buffer.h
@@ -198,9 +198,7 @@ class AliasedBuffer {
* Set position index to given value.
*/
inline void SetValue(const size_t index, NativeT value) {
-#if defined(DEBUG) && DEBUG
- CHECK_LT(index, count_);
-#endif
+ DCHECK_LT(index, count_);
buffer_[index] = value;
}
@@ -208,9 +206,7 @@ class AliasedBuffer {
* Get value at position index
*/
inline const NativeT GetValue(const size_t index) const {
-#if defined(DEBUG) && DEBUG
- CHECK_LT(index, count_);
-#endif
+ DCHECK_LT(index, count_);
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
// an owning `AliasedBuffer`.
void reserve(size_t new_capacity) {
+ DCHECK_GE(new_capacity, count_);
+ DCHECK_EQ(byte_offset_, 0);
#if defined(DEBUG) && DEBUG
- CHECK_GE(new_capacity, count_);
- CHECK_EQ(byte_offset_, 0);
CHECK(free_buffer_);
#endif
const v8::HandleScope handle_scope(isolate_);
diff --git a/src/base_object-inl.h b/src/base_object-inl.h
index cce8727393..84c449a308 100644
--- a/src/base_object-inl.h
+++ b/src/base_object-inl.h
@@ -115,8 +115,8 @@ BaseObject::MakeLazilyInitializedJSTemplate(Environment* env) {
auto constructor = [](const v8::FunctionCallbackInfo<v8::Value>& args) {
#ifdef DEBUG
CHECK(args.IsConstructCall());
- CHECK_GT(args.This()->InternalFieldCount(), 0);
#endif
+ DCHECK_GT(args.This()->InternalFieldCount(), 0);
args.This()->SetAlignedPointerInInternalField(0, nullptr);
};
diff --git a/src/debug_utils.h b/src/debug_utils.h
index 034d8a9ab3..ed5e42fcbe 100644
--- a/src/debug_utils.h
+++ b/src/debug_utils.h
@@ -68,9 +68,7 @@ template <typename... Args>
inline void FORCE_INLINE Debug(AsyncWrap* async_wrap,
const char* format,
Args&&... args) {
-#ifdef DEBUG
- CHECK_NOT_NULL(async_wrap);
-#endif
+ DCHECK_NOT_NULL(async_wrap);
DebugCategory cat =
static_cast<DebugCategory>(async_wrap->provider_type());
if (!UNLIKELY(async_wrap->env()->debug_enabled(cat)))
diff --git a/src/string_decoder.cc b/src/string_decoder.cc
index a83d6623b4..96c6baa4d8 100644
--- a/src/string_decoder.cc
+++ b/src/string_decoder.cc
@@ -123,11 +123,9 @@ MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
body = !prepend.IsEmpty() ? prepend : String::Empty(isolate);
prepend = Local<String>();
} else {
-#ifdef DEBUG
// If not, that means is no character left to finish at this point.
- CHECK_EQ(MissingBytes(), 0);
- CHECK_EQ(BufferedBytes(), 0);
-#endif
+ DCHECK_EQ(MissingBytes(), 0);
+ DCHECK_EQ(BufferedBytes(), 0);
// See whether there is a character that we may have to cut off and
// 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
// the byte belongs begins.
for (size_t i = nread - 1; ; --i) {
-#ifdef DEBUG
- CHECK_LT(i, nread);
-#endif
+ DCHECK_LT(i, nread);
state_[kBufferedBytes]++;
if ((data[i] & 0xC0) == 0x80) {
// This byte does not start a character (a "trailing" byte).
diff --git a/src/string_search.h b/src/string_search.h
index 358a4c1b02..7d59d89df7 100644
--- a/src/string_search.h
+++ b/src/string_search.h
@@ -37,9 +37,7 @@ class Vector {
// Access individual vector elements - checks bounds in debug mode.
T& operator[](size_t index) const {
-#ifdef DEBUG
- CHECK(index < length_);
-#endif
+ DCHECK_LT(index, length_);
return start_[is_forward_ ? index : (length_ - index - 1)];
}