Skip to content

Commit d00b795

Browse files
ldm5180linusg
authored andcommitted
Libraries: Use default constructors/destructors in LibJS
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
1 parent 07c7827 commit d00b795

File tree

192 files changed

+104
-492
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

192 files changed

+104
-492
lines changed

Userland/Libraries/LibJS/AST.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ create_ast_node(SourceRange range, Args&&... args)
4646

4747
class ASTNode : public RefCounted<ASTNode> {
4848
public:
49-
virtual ~ASTNode() { }
49+
virtual ~ASTNode() = default;
5050
virtual Completion execute(Interpreter&, GlobalObject&) const = 0;
5151
virtual Bytecode::CodeGenerationErrorOr<void> generate_bytecode(Bytecode::Generator&) const;
5252
virtual void dump(int indent) const;

Userland/Libraries/LibJS/Bytecode/Generator.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ Generator::Generator()
1919
{
2020
}
2121

22-
Generator::~Generator()
23-
{
24-
}
25-
2622
CodeGenerationErrorOr<NonnullOwnPtr<Executable>> Generator::generate(ASTNode const& node, FunctionKind enclosing_function_kind)
2723
{
2824
Generator generator;

Userland/Libraries/LibJS/Bytecode/Generator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class Generator {
194194

195195
private:
196196
Generator();
197-
~Generator();
197+
~Generator() = default;
198198

199199
void grow(size_t);
200200
void* next_slot();

Userland/Libraries/LibJS/Heap/BlockAllocator.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
namespace JS {
1919

20-
BlockAllocator::BlockAllocator()
21-
{
22-
}
23-
2420
BlockAllocator::~BlockAllocator()
2521
{
2622
for (auto* block : m_blocks) {

Userland/Libraries/LibJS/Heap/BlockAllocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace JS {
1313

1414
class BlockAllocator {
1515
public:
16-
BlockAllocator();
16+
BlockAllocator() = default;
1717
~BlockAllocator();
1818

1919
void* allocate_block(char const* name);

Userland/Libraries/LibJS/Heap/Cell.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Cell {
1919

2020
public:
2121
virtual void initialize(GlobalObject&) { }
22-
virtual ~Cell() { }
22+
virtual ~Cell() = default;
2323

2424
bool is_marked() const { return m_mark; }
2525
void set_marked(bool b) { m_mark = b; }
@@ -55,7 +55,7 @@ class Cell {
5555
VM& vm() const;
5656

5757
protected:
58-
Cell() { }
58+
Cell() = default;
5959

6060
private:
6161
bool m_mark : 1 { false };

Userland/Libraries/LibJS/Heap/Heap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ __attribute__((no_sanitize("address"))) void Heap::gather_conservative_roots(Has
173173

174174
class MarkingVisitor final : public Cell::Visitor {
175175
public:
176-
MarkingVisitor() { }
176+
MarkingVisitor() = default;
177177

178178
virtual void visit_impl(Cell& cell) override
179179
{

Userland/Libraries/LibJS/Interpreter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ Interpreter::Interpreter(VM& vm)
3636
{
3737
}
3838

39-
Interpreter::~Interpreter()
40-
{
41-
}
42-
4339
// 16.1.6 ScriptEvaluation ( scriptRecord ), https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation
4440
ThrowCompletionOr<Value> Interpreter::run(Script& script_record)
4541
{

Userland/Libraries/LibJS/Interpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Interpreter : public Weakable<Interpreter> {
101101

102102
static NonnullOwnPtr<Interpreter> create_with_existing_realm(Realm&);
103103

104-
~Interpreter();
104+
~Interpreter() = default;
105105

106106
ThrowCompletionOr<Value> run(Script&);
107107
ThrowCompletionOr<Value> run(SourceTextModule&);

Userland/Libraries/LibJS/Module.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ Module::Module(Realm& realm, String filename)
1717
{
1818
}
1919

20-
Module::~Module()
21-
{
22-
}
23-
2420
// 16.2.1.5.1.1 InnerModuleLinking ( module, stack, index ), https://tc39.es/ecma262/#sec-InnerModuleLinking
2521
ThrowCompletionOr<u32> Module::inner_module_linking(VM& vm, Vector<Module*>&, u32 index)
2622
{

0 commit comments

Comments
 (0)