return !IsEmpty();
}
- // Will crash when checks are enabled if the MaybeLocal<> is empty.
+ // Will crash if the MaybeLocal<> is empty.
V8_INLINE Local<T> ToLocalChecked();
template <class S>
int* index);
static Local<Value> GetEternal(Isolate* isolate, int index);
- static void CheckIsJust(bool is_just);
+ static void FromJustIsNothing();
static void ToLocalEmpty();
static void InternalFieldOutOfBounds(int index);
V8_INLINE bool IsNothing() const { return !has_value; }
V8_INLINE bool IsJust() const { return has_value; }
- // Will crash when checks are enabled if the Maybe<> is nothing.
+ // Will crash if the Maybe<> is nothing.
V8_INLINE T FromJust() const {
-#ifdef V8_ENABLE_CHECKS
- V8::CheckIsJust(IsJust());
-#endif
+ if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing();
return value;
}
template <class T>
Local<T> MaybeLocal<T>::ToLocalChecked() {
-#ifdef V8_ENABLE_CHECKS
- if (val_ == nullptr) V8::ToLocalEmpty();
-#endif
+ if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty();
return Local<T>(val_);
}
}
-void V8::CheckIsJust(bool is_just) {
- Utils::ApiCheck(is_just, "v8::FromJust", "Maybe value is Nothing.");
+void V8::FromJustIsNothing() {
+ Utils::ApiCheck(false, "v8::FromJust", "Maybe value is Nothing.");
}