Skip to content

Commit 602eb98

Browse files
committed
src: refactored and removed some ifdef debug statements
test: fixed order of actual and expected arguments src: ifdef changes src: refactored and removed some ifdef debug statements
1 parent 4c88f36 commit 602eb98

File tree

5 files changed

+31
-38
lines changed

5 files changed

+31
-38
lines changed

src/base_object-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ v8::Local<v8::Object> BaseObject::object() const {
6868
v8::Local<v8::Object> BaseObject::object(v8::Isolate* isolate) const {
6969
v8::Local<v8::Object> handle = object();
7070

71-
CHECK_EQ(handle->CreationContext()->GetIsolate(), isolate);
72-
CHECK_EQ(env_->isolate(), isolate);
71+
DCHECK_EQ(handle->CreationContext()->GetIsolate(), isolate);
72+
DCHECK_EQ(env_->isolate(), isolate);
7373

7474
return handle;
7575
}

src/env-inl.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -549,20 +549,16 @@ inline void Environment::set_http2_state(
549549
}
550550

551551
bool Environment::debug_enabled(DebugCategory category) const {
552-
#ifdef DEBUG
553-
CHECK_GE(static_cast<int>(category), 0);
554-
CHECK_LT(static_cast<int>(category),
552+
DCHECK_GE(static_cast<int>(category), 0);
553+
DCHECK_LT(static_cast<int>(category),
555554
static_cast<int>(DebugCategory::CATEGORY_COUNT));
556-
#endif
557555
return debug_enabled_[static_cast<int>(category)];
558556
}
559557

560558
void Environment::set_debug_enabled(DebugCategory category, bool enabled) {
561-
#ifdef DEBUG
562-
CHECK_GE(static_cast<int>(category), 0);
563-
CHECK_LT(static_cast<int>(category),
559+
DCHECK_GE(static_cast<int>(category), 0);
560+
DCHECK_LT(static_cast<int>(category),
564561
static_cast<int>(DebugCategory::CATEGORY_COUNT));
565-
#endif
566562
debug_enabled_[static_cast<int>(category)] = enabled;
567563
}
568564

src/env.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,7 @@ void Environment::RunAndClearNativeImmediates() {
591591
};
592592
while (drain_list()) {}
593593

594-
#ifdef DEBUG
595-
CHECK_GE(immediate_info()->count(), count);
596-
#endif
594+
DCHECK_GE(immediate_info()->count(), count);
597595
immediate_info()->count_dec(count);
598596
immediate_info()->ref_count_dec(ref_count);
599597
}

src/stream_base.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,17 +292,16 @@ void StreamBase::CallJSOnreadMethod(ssize_t nread,
292292
size_t offset) {
293293
Environment* env = env_;
294294

295-
#ifdef DEBUG
296-
CHECK_EQ(static_cast<int32_t>(nread), nread);
297-
CHECK_LE(offset, INT32_MAX);
295+
DCHECK_EQ(static_cast<int32_t>(nread), nread);
296+
DCHECK_LE(offset, INT32_MAX);
298297

299298
if (ab.IsEmpty()) {
300-
CHECK_EQ(offset, 0);
301-
CHECK_LE(nread, 0);
299+
DCHECK_EQ(offset, 0);
300+
DCHECK_LE(nread, 0);
302301
} else {
303-
CHECK_GE(nread, 0);
302+
DCHECK_GE(nread, 0);
304303
}
305-
#endif
304+
306305
env->stream_base_state()[kReadBytesOrError] = nread;
307306
env->stream_base_state()[kArrayBufferOffset] = offset;
308307

src/util.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,25 @@ void DumpBacktrace(FILE* fp);
129129
#define CHECK_IMPLIES(a, b) CHECK(!(a) || (b))
130130

131131
#ifdef DEBUG
132-
#define DCHECK_EQ(a, b) CHECK((a) == (b))
133-
#define DCHECK_GE(a, b) CHECK((a) >= (b))
134-
#define DCHECK_GT(a, b) CHECK((a) > (b))
135-
#define DCHECK_LE(a, b) CHECK((a) <= (b))
136-
#define DCHECK_LT(a, b) CHECK((a) < (b))
137-
#define DCHECK_NE(a, b) CHECK((a) != (b))
138-
#define DCHECK_NULL(val) CHECK((val) == nullptr)
139-
#define DCHECK_NOT_NULL(val) CHECK((val) != nullptr)
140-
#define DCHECK_IMPLIES(a, b) CHECK(!(a) || (b))
132+
#define DCHECK_EQ(a, b) CHECK((a) == (b))
133+
#define DCHECK_GE(a, b) CHECK((a) >= (b))
134+
#define DCHECK_GT(a, b) CHECK((a) > (b))
135+
#define DCHECK_LE(a, b) CHECK((a) <= (b))
136+
#define DCHECK_LT(a, b) CHECK((a) < (b))
137+
#define DCHECK_NE(a, b) CHECK((a) != (b))
138+
#define DCHECK_NULL(val) CHECK((val) == nullptr)
139+
#define DCHECK_NOT_NULL(val) CHECK((val) != nullptr)
140+
#define DCHECK_IMPLIES(a, b) CHECK(!(a) || (b))
141141
#else
142-
#define DCHECK_EQ(a, b)
143-
#define DCHECK_GE(a, b)
144-
#define DCHECK_GT(a, b)
145-
#define DCHECK_LE(a, b)
146-
#define DCHECK_LT(a, b)
147-
#define DCHECK_NE(a, b)
148-
#define DCHECK_NULL(val)
149-
#define DCHECK_NOT_NULL(val)
150-
#define DCHECK_IMPLIES(a, b)
142+
#define DCHECK_EQ(a, b)
143+
#define DCHECK_GE(a, b)
144+
#define DCHECK_GT(a, b)
145+
#define DCHECK_LE(a, b)
146+
#define DCHECK_LT(a, b)
147+
#define DCHECK_NE(a, b)
148+
#define DCHECK_NULL(val)
149+
#define DCHECK_NOT_NULL(val)
150+
#define DCHECK_IMPLIES(a, b)
151151
#endif
152152

153153

0 commit comments

Comments
 (0)