Skip to content

Commit 3fb678b

Browse files
committed
LibGC: Delete operators ! and bool from GC::Ref
The GC::Ref smart pointer is always non-null, so there's no need for it to be convertible to bool. This exposed a small number of unnecessary null checks which we remove.
1 parent e4e18ca commit 3fb678b

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

Libraries/LibGC/Ptr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ class Ref {
7171

7272
operator T&() const { return *m_ptr; }
7373

74+
operator bool() const = delete;
75+
bool operator!() const = delete;
76+
7477
private:
7578
T* m_ptr { nullptr };
7679
};

Libraries/LibJS/AST.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ ThrowCompletionOr<ECMAScriptFunctionObject*> ClassExpression::create_class_const
322322
}
323323

324324
auto prototype = Object::create_prototype(realm, proto_parent);
325-
VERIFY(prototype);
326325

327326
// FIXME: Step 14.a is done in the parser. By using a synthetic super(...args) which does not call @@iterator of %Array.prototype%
328327
auto const& constructor = *m_constructor;

Libraries/LibJS/Bytecode/Interpreter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,6 @@ static Value instantiate_ordinary_function_expression(Interpreter& interpreter,
13441344

13451345
auto environment = GC::Ref { *interpreter.running_execution_context().lexical_environment };
13461346
if (has_own_name) {
1347-
VERIFY(environment);
13481347
environment = new_declarative_environment(*environment);
13491348
MUST(environment->create_immutable_binding(interpreter.vm(), own_name, false));
13501349
}

0 commit comments

Comments
 (0)