Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2a01ca

Browse filesBrowse files
cjihrigtargos
authored andcommitted
src: use DCHECK_* macros where possible
PR-URL: #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>
1 parent 39b3fd1 commit e2a01ca
Copy full SHA for e2a01ca

File tree

Expand file treeCollapse file tree

5 files changed

+10
-22
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+10
-22
lines changed
Open diff view settings
Collapse file

‎src/aliased_buffer.h‎

Copy file name to clipboardExpand all lines: src/aliased_buffer.h
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,15 @@ class AliasedBuffer {
198198
* Set position index to given value.
199199
*/
200200
inline void SetValue(const size_t index, NativeT value) {
201-
#if defined(DEBUG) && DEBUG
202-
CHECK_LT(index, count_);
203-
#endif
201+
DCHECK_LT(index, count_);
204202
buffer_[index] = value;
205203
}
206204

207205
/**
208206
* Get value at position index
209207
*/
210208
inline const NativeT GetValue(const size_t index) const {
211-
#if defined(DEBUG) && DEBUG
212-
CHECK_LT(index, count_);
213-
#endif
209+
DCHECK_LT(index, count_);
214210
return buffer_[index];
215211
}
216212

@@ -233,9 +229,9 @@ class AliasedBuffer {
233229
// Should only be used on an owning array, not one created as a sub array of
234230
// an owning `AliasedBuffer`.
235231
void reserve(size_t new_capacity) {
232+
DCHECK_GE(new_capacity, count_);
233+
DCHECK_EQ(byte_offset_, 0);
236234
#if defined(DEBUG) && DEBUG
237-
CHECK_GE(new_capacity, count_);
238-
CHECK_EQ(byte_offset_, 0);
239235
CHECK(free_buffer_);
240236
#endif
241237
const v8::HandleScope handle_scope(isolate_);
Collapse file

‎src/base_object-inl.h‎

Copy file name to clipboardExpand all lines: src/base_object-inl.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ BaseObject::MakeLazilyInitializedJSTemplate(Environment* env) {
115115
auto constructor = [](const v8::FunctionCallbackInfo<v8::Value>& args) {
116116
#ifdef DEBUG
117117
CHECK(args.IsConstructCall());
118-
CHECK_GT(args.This()->InternalFieldCount(), 0);
119118
#endif
119+
DCHECK_GT(args.This()->InternalFieldCount(), 0);
120120
args.This()->SetAlignedPointerInInternalField(0, nullptr);
121121
};
122122

Collapse file

‎src/debug_utils.h‎

Copy file name to clipboardExpand all lines: src/debug_utils.h
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ template <typename... Args>
6868
inline void FORCE_INLINE Debug(AsyncWrap* async_wrap,
6969
const char* format,
7070
Args&&... args) {
71-
#ifdef DEBUG
72-
CHECK_NOT_NULL(async_wrap);
73-
#endif
71+
DCHECK_NOT_NULL(async_wrap);
7472
DebugCategory cat =
7573
static_cast<DebugCategory>(async_wrap->provider_type());
7674
if (!UNLIKELY(async_wrap->env()->debug_enabled(cat)))
Collapse file

‎src/string_decoder.cc‎

Copy file name to clipboardExpand all lines: src/string_decoder.cc
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,9 @@ MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
123123
body = !prepend.IsEmpty() ? prepend : String::Empty(isolate);
124124
prepend = Local<String>();
125125
} else {
126-
#ifdef DEBUG
127126
// If not, that means is no character left to finish at this point.
128-
CHECK_EQ(MissingBytes(), 0);
129-
CHECK_EQ(BufferedBytes(), 0);
130-
#endif
127+
DCHECK_EQ(MissingBytes(), 0);
128+
DCHECK_EQ(BufferedBytes(), 0);
131129

132130
// See whether there is a character that we may have to cut off and
133131
// finish when receiving the next chunk.
@@ -136,9 +134,7 @@ MaybeLocal<String> StringDecoder::DecodeData(Isolate* isolate,
136134
// This means we'll need to figure out where the character to which
137135
// the byte belongs begins.
138136
for (size_t i = nread - 1; ; --i) {
139-
#ifdef DEBUG
140-
CHECK_LT(i, nread);
141-
#endif
137+
DCHECK_LT(i, nread);
142138
state_[kBufferedBytes]++;
143139
if ((data[i] & 0xC0) == 0x80) {
144140
// This byte does not start a character (a "trailing" byte).
Collapse file

‎src/string_search.h‎

Copy file name to clipboardExpand all lines: src/string_search.h
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ class Vector {
3737

3838
// Access individual vector elements - checks bounds in debug mode.
3939
T& operator[](size_t index) const {
40-
#ifdef DEBUG
41-
CHECK(index < length_);
42-
#endif
40+
DCHECK_LT(index, length_);
4341
return start_[is_forward_ ? index : (length_ - index - 1)];
4442
}
4543

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.