From d24427dcc8cd6e0dbcd8c302eb2e8a5d0d6fdead Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 15 Jan 2019 13:20:05 -0800 Subject: Code style improvements (#1868) * Use modern T p = v; notation to initialize class fields * Use modern X() = default; notation for empty class constructors --- src/emscripten-optimizer/simple_ast.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/emscripten-optimizer/simple_ast.h') diff --git a/src/emscripten-optimizer/simple_ast.h b/src/emscripten-optimizer/simple_ast.h index 9cbe7616c..de8122ba1 100644 --- a/src/emscripten-optimizer/simple_ast.h +++ b/src/emscripten-optimizer/simple_ast.h @@ -112,7 +112,7 @@ struct Value { AssignName_ = 7 }; - Type type; + Type type = Null; typedef std::unordered_map ObjectStorage; @@ -131,14 +131,14 @@ struct Value { }; // constructors all copy their input - Value() : type(Null), num(0) {} - explicit Value(const char *s) : type(Null) { + Value() {} + explicit Value(const char *s) { setString(s); } - explicit Value(double n) : type(Null) { + explicit Value(double n) { setNumber(n); } - explicit Value(ArrayStorage &a) : type(Null) { + explicit Value(ArrayStorage &a) { setArray(); *arr = a; } @@ -544,15 +544,16 @@ void traverseFunctions(Ref ast, std::function visit); struct JSPrinter { bool pretty, finalize; - char *buffer; - size_t size, used; + char *buffer = nullptr; + size_t size = 0; + size_t used = 0; - int indent; - bool possibleSpace; // add a space to separate identifiers + int indent = 0; + bool possibleSpace = false; // add a space to separate identifiers Ref ast; - JSPrinter(bool pretty_, bool finalize_, Ref ast_) : pretty(pretty_), finalize(finalize_), buffer(0), size(0), used(0), indent(0), possibleSpace(false), ast(ast_) {} + JSPrinter(bool pretty_, bool finalize_, Ref ast_) : pretty(pretty_), finalize(finalize_), ast(ast_) {} ~JSPrinter() { free(buffer); -- cgit v1.2.3