Moved member variables from constructor to initialization list

This commit is contained in:
Wilson E. Alvarez 2017-07-30 19:07:04 -04:00
parent 950b205609
commit 6d112a68b6
22 changed files with 196 additions and 215 deletions

View File

@ -46,9 +46,9 @@
#ifdef DEBUG_METHODS_ENABLED
ParamDef::ParamDef(const Variant &p_variant) {
used = true;
val = p_variant;
ParamDef::ParamDef(const Variant &p_variant)
: used(true),
val(p_variant) {
}
MethodDefinition D_METHOD(const char *p_name) {

View File

@ -45,12 +45,11 @@ struct ParamHint {
String hint_text;
Variant default_val;
ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", Variant p_default_val = Variant()) {
name = p_name;
hint = p_hint;
hint_text = p_hint_text;
default_val = p_default_val;
ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", Variant p_default_val = Variant())
: name(p_name),
hint(p_hint),
hint_text(p_hint_text),
default_val(p_default_val) {
}
};
@ -73,8 +72,10 @@ struct MethodDefinition {
StringName name;
Vector<StringName> args;
MethodDefinition() {}
MethodDefinition(const char *p_name) { name = p_name; }
MethodDefinition(const StringName &p_name) { name = p_name; }
MethodDefinition(const char *p_name)
: name(p_name) {}
MethodDefinition(const StringName &p_name)
: name(p_name) {}
};
MethodDefinition D_METHOD(const char *p_name);

View File

@ -31,21 +31,20 @@
CoreStringNames *CoreStringNames::singleton = NULL;
CoreStringNames::CoreStringNames() {
_free = StaticCString::create("free");
changed = StaticCString::create("changed");
_meta = StaticCString::create("__meta__");
_script = StaticCString::create("script");
script_changed = StaticCString::create("script_changed");
___pdcdata = StaticCString::create("___pdcdata");
__getvar = StaticCString::create("__getvar");
_iter_init = StaticCString::create("_iter_init");
_iter_next = StaticCString::create("_iter_next");
_iter_get = StaticCString::create("_iter_get");
get_rid = StaticCString::create("get_rid");
_custom_features = StaticCString::create("_custom_features");
CoreStringNames::CoreStringNames()
: _free(StaticCString::create("free")),
changed(StaticCString::create("changed")),
_meta(StaticCString::create("__meta__")),
_script(StaticCString::create("script")),
script_changed(StaticCString::create("script_changed")),
___pdcdata(StaticCString::create("___pdcdata")),
__getvar(StaticCString::create("__getvar")),
_iter_init(StaticCString::create("_iter_init")),
_iter_next(StaticCString::create("_iter_next")),
_iter_get(StaticCString::create("_iter_get")),
get_rid(StaticCString::create("get_rid")),
#ifdef TOOLS_ENABLED
_sections_unfolded = StaticCString::create("_sections_unfolded");
_sections_unfolded(StaticCString::create("_sections_unfolded")),
#endif
_custom_features(StaticCString::create("_custom_features")) {
}

View File

@ -61,10 +61,10 @@ public:
StringName _iter_next;
StringName _iter_get;
StringName get_rid;
StringName _custom_features;
#ifdef TOOLS_ENABLED
StringName _sections_unfolded;
#endif
StringName _custom_features;
};
#endif // SCENE_STRING_NAMES_H

View File

@ -96,9 +96,9 @@ public:
TData data;
Pair() {}
Pair(const TKey &p_key, const TData &p_data) {
key = p_key;
data = p_data;
Pair(const TKey &p_key, const TData &p_data)
: key(p_key),
data(p_data) {
}
};

View File

@ -308,10 +308,9 @@ bool FileAccessPack::file_exists(const String &p_name) {
return false;
}
FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) {
pf = p_file;
f = FileAccess::open(pf.pack, FileAccess::READ);
FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file)
: pf(p_file),
f(FileAccess::open(pf.pack, FileAccess::READ)) {
if (!f) {
ERR_EXPLAIN("Can't open pack-referenced file: " + String(pf.pack));
ERR_FAIL_COND(!f);

View File

@ -85,9 +85,9 @@ public:
PropertyInfo option;
Variant default_value;
ImportOption(const PropertyInfo &p_info, const Variant &p_default) {
option = p_info;
default_value = p_default;
ImportOption(const PropertyInfo &p_info, const Variant &p_default)
: option(p_info),
default_value(p_default) {
}
ImportOption() {}
};

View File

@ -577,12 +577,11 @@ BSP_Tree::BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius) {
error_radius = p_error_radius;
}
BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius) {
nodes = p_nodes;
planes = p_planes;
aabb = p_aabb;
error_radius = p_error_radius;
BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius)
: nodes(p_nodes),
planes(p_planes),
aabb(p_aabb),
error_radius(p_error_radius) {
}
BSP_Tree::~BSP_Tree() {

View File

@ -378,13 +378,13 @@ struct Rect2 {
operator String() const { return String(position) + ", " + String(size); }
Rect2() {}
Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) {
position = Point2(p_x, p_y);
size = Size2(p_width, p_height);
Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height)
: position(Point2(p_x, p_y)),
size(Size2(p_width, p_height)) {
}
Rect2(const Point2 &p_pos, const Size2 &p_size) {
position = p_pos;
size = p_size;
Rect2(const Point2 &p_pos, const Size2 &p_size)
: position(p_pos),
size(p_size) {
}
};
@ -571,18 +571,18 @@ struct Rect2i {
operator String() const { return String(position) + ", " + String(size); }
operator Rect2() const { return Rect2(position, size); }
Rect2i(const Rect2 &p_r2) {
position = p_r2.position;
size = p_r2.size;
Rect2i(const Rect2 &p_r2)
: position(p_r2.position),
size(p_r2.size) {
}
Rect2i() {}
Rect2i(int p_x, int p_y, int p_width, int p_height) {
position = Point2(p_x, p_y);
size = Size2(p_width, p_height);
Rect2i(int p_x, int p_y, int p_width, int p_height)
: position(Point2(p_x, p_y)),
size(Size2(p_width, p_height)) {
}
Rect2i(const Point2 &p_pos, const Size2 &p_size) {
position = p_pos;
size = p_size;
Rect2i(const Point2 &p_pos, const Size2 &p_size)
: position(p_pos),
size(p_size) {
}
};

View File

@ -75,7 +75,8 @@ public:
_FORCE_INLINE_ Plane() { d = 0; }
_FORCE_INLINE_ Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d)
: normal(p_a, p_b, p_c), d(p_d){};
: normal(p_a, p_b, p_c),
d(p_d){};
_FORCE_INLINE_ Plane(const Vector3 &p_normal, real_t p_d);
_FORCE_INLINE_ Plane(const Vector3 &p_point, const Vector3 &p_normal);
@ -99,16 +100,14 @@ bool Plane::has_point(const Vector3 &p_point, real_t _epsilon) const {
return (dist <= _epsilon);
}
Plane::Plane(const Vector3 &p_normal, real_t p_d) {
normal = p_normal;
d = p_d;
Plane::Plane(const Vector3 &p_normal, real_t p_d)
: normal(p_normal),
d(p_d) {
}
Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal) {
normal = p_normal;
d = p_normal.dot(p_point);
Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal)
: normal(p_normal),
d(p_normal.dot(p_point)) {
}
Plane::Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir) {

View File

@ -101,9 +101,9 @@ public:
operator String() const;
_FORCE_INLINE_ Rect3() {}
inline Rect3(const Vector3 &p_pos, const Vector3 &p_size) {
position = p_pos;
size = p_size;
inline Rect3(const Vector3 &p_pos, const Vector3 &p_size)
: position(p_pos),
size(p_size) {
}
};

View File

@ -208,8 +208,7 @@ Transform::operator String() const {
return basis.operator String() + " - " + origin.operator String();
}
Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) {
basis = p_basis;
origin = p_origin;
Transform::Transform(const Basis &p_basis, const Vector3 &p_origin)
: basis(p_basis),
origin(p_origin) {
}

View File

@ -122,10 +122,9 @@ MethodInfo::operator Dictionary() const {
return d;
}
MethodInfo::MethodInfo() {
id = 0;
flags = METHOD_FLAG_NORMAL;
MethodInfo::MethodInfo()
: flags(METHOD_FLAG_NORMAL),
id(0) {
}
MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
@ -161,125 +160,114 @@ MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) {
return mi;
}
MethodInfo::MethodInfo(const String &p_name) {
id = 0;
name = p_name;
flags = METHOD_FLAG_NORMAL;
MethodInfo::MethodInfo(const String &p_name)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
}
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
arguments.push_back(p_param1);
flags = METHOD_FLAG_NORMAL;
}
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
flags = METHOD_FLAG_NORMAL;
}
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
flags = METHOD_FLAG_NORMAL;
}
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
arguments.push_back(p_param4);
flags = METHOD_FLAG_NORMAL;
}
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
arguments.push_back(p_param4);
arguments.push_back(p_param5);
flags = METHOD_FLAG_NORMAL;
}
MethodInfo::MethodInfo(Variant::Type ret) {
id = 0;
flags = METHOD_FLAG_NORMAL;
MethodInfo::MethodInfo(Variant::Type ret)
: flags(METHOD_FLAG_NORMAL),
id(0) {
return_val.type = ret;
}
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name) {
id = 0;
name = p_name;
flags = METHOD_FLAG_NORMAL;
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
return_val.type = ret;
}
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
return_val.type = ret;
arguments.push_back(p_param1);
flags = METHOD_FLAG_NORMAL;
return_val.type = ret;
}
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
flags = METHOD_FLAG_NORMAL;
return_val.type = ret;
}
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
flags = METHOD_FLAG_NORMAL;
return_val.type = ret;
}
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
arguments.push_back(p_param4);
flags = METHOD_FLAG_NORMAL;
return_val.type = ret;
}
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) {
id = 0;
name = p_name;
MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5)
: name(p_name),
flags(METHOD_FLAG_NORMAL),
id(0) {
return_val.type = ret;
arguments.push_back(p_param1);
arguments.push_back(p_param2);
arguments.push_back(p_param3);
arguments.push_back(p_param4);
arguments.push_back(p_param5);
flags = METHOD_FLAG_NORMAL;
return_val.type = ret;
}
Object::Connection::operator Variant() const {

View File

@ -139,17 +139,17 @@ struct PropertyInfo {
static PropertyInfo from_dict(const Dictionary &p_dict);
PropertyInfo() {
type = Variant::NIL;
hint = PROPERTY_HINT_NONE;
usage = PROPERTY_USAGE_DEFAULT;
PropertyInfo()
: type(Variant::NIL),
hint(PROPERTY_HINT_NONE),
usage(PROPERTY_USAGE_DEFAULT) {
}
PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT) {
type = p_type;
name = p_name;
hint = p_hint;
hint_string = p_hint_string;
usage = p_usage;
PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT)
: type(p_type),
name(p_name),
hint(p_hint),
hint_string(p_hint_string),
usage(p_usage) {
}
bool operator<(const PropertyInfo &p_info) const {
return name < p_info.name;
@ -401,9 +401,9 @@ private:
_FORCE_INLINE_ bool operator<(const Target &p_target) const { return (_id == p_target._id) ? (method < p_target.method) : (_id < p_target._id); }
Target(const ObjectID &p_id, const StringName &p_method) {
_id = p_id;
method = p_method;
Target(const ObjectID &p_id, const StringName &p_method)
: _id(p_id),
method(p_method) {
}
Target() { _id = 0; }
};

View File

@ -37,9 +37,9 @@ struct Pair {
S second;
Pair() {}
Pair(F p_first, S p_second) {
first = p_first;
second = p_second;
Pair(F p_first, S p_second)
: first(p_first),
second(p_second) {
}
};

View File

@ -48,9 +48,9 @@ public:
struct Singleton {
StringName name;
Object *ptr;
Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) {
name = p_name;
ptr = p_ptr;
Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL)
: name(p_name),
ptr(p_ptr) {
}
};
enum {
@ -66,18 +66,18 @@ protected:
Variant initial;
bool hide_from_editor;
bool overrided;
VariantContainer() {
order = 0;
hide_from_editor = false;
persist = false;
overrided = false;
VariantContainer()
: order(0),
persist(false),
hide_from_editor(false),
overrided(false) {
}
VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) {
variant = p_variant;
order = p_order;
hide_from_editor = false;
persist = p_persist;
overrided = false;
VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false)
: order(p_order),
persist(p_persist),
variant(p_variant),
hide_from_editor(false),
overrided(false) {
}
};

View File

@ -940,29 +940,32 @@ void ScriptDebuggerRemote::profiling_set_frame_times(float p_frame_time, float p
ScriptDebuggerRemote::ResourceUsageFunc ScriptDebuggerRemote::resource_usage_func = NULL;
ScriptDebuggerRemote::ScriptDebuggerRemote() {
ScriptDebuggerRemote::ScriptDebuggerRemote()
: profiling(false),
max_frame_functions(16),
skip_profile_frame(false),
reload_all_scripts(false),
tcp_client(StreamPeerTCP::create_ref()),
packet_peer_stream(Ref<PacketPeerStream>(memnew(PacketPeerStream))),
last_perf_time(0),
performance(ProjectSettings::get_singleton()->get_singleton_object("Performance")),
requested_quit(false),
mutex(Mutex::create()),
max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")),
char_count(0),
last_msec(0),
msec_count(0),
locking(false),
poll_every(0),
request_scene_tree(NULL),
live_edit_funcs(NULL) {
tcp_client = StreamPeerTCP::create_ref();
packet_peer_stream = Ref<PacketPeerStream>(memnew(PacketPeerStream));
packet_peer_stream->set_stream_peer(tcp_client);
packet_peer_stream->set_output_buffer_max_size(1024 * 1024 * 8); //8mb should be way more than enough
mutex = Mutex::create();
locking = false;
phl.printfunc = _print_handler;
phl.userdata = this;
add_print_handler(&phl);
requested_quit = false;
performance = ProjectSettings::get_singleton()->get_singleton_object("Performance");
last_perf_time = 0;
poll_every = 0;
request_scene_tree = NULL;
live_edit_funcs = NULL;
max_cps = GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second");
char_count = 0;
msec_count = 0;
last_msec = 0;
skip_profile_frame = false;
eh.errfunc = _err_handler;
eh.userdata = this;
@ -970,9 +973,6 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() {
profile_info.resize(CLAMP(int(ProjectSettings::get_singleton()->get("debug/settings/profiler/max_functions")), 128, 65535));
profile_info_ptrs.resize(profile_info.size());
profiling = false;
max_frame_functions = 16;
reload_all_scripts = false;
}
ScriptDebuggerRemote::~ScriptDebuggerRemote() {

View File

@ -384,11 +384,10 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c
//change notify
}
PlaceHolderScriptInstance::PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner) {
language = p_language;
script = p_script;
owner = p_owner;
PlaceHolderScriptInstance::PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner)
: owner(p_owner),
language(p_language),
script(p_script) {
}
PlaceHolderScriptInstance::~PlaceHolderScriptInstance() {

View File

@ -923,9 +923,8 @@ void Translation::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale");
}
Translation::Translation() {
locale = "en";
Translation::Translation()
: locale("en") {
}
///////////////////////////////////////////////
@ -1144,9 +1143,8 @@ void TranslationServer::load_translations() {
}
}
TranslationServer::TranslationServer() {
TranslationServer::TranslationServer()
: locale("en"),
enabled(true) {
singleton = this;
locale = "en";
enabled = true;
}

View File

@ -130,9 +130,9 @@ struct _VariantCall {
StringName name;
Variant::Type type;
Arg() { type = Variant::NIL; }
Arg(Variant::Type p_type, const StringName &p_name) {
name = p_name;
type = p_type;
Arg(Variant::Type p_type, const StringName &p_name)
: name(p_name),
type(p_type) {
}
};

View File

@ -57,9 +57,9 @@ class Navigation2D : public Node2D {
return (a.key == p_key.a.key) ? (b.key < p_key.b.key) : (a.key < p_key.a.key);
};
EdgeKey(const Point &p_a = Point(), const Point &p_b = Point()) {
a = p_a;
b = p_b;
EdgeKey(const Point &p_a = Point(), const Point &p_b = Point())
: a(p_a),
b(p_b) {
if (a.key > b.key) {
SWAP(a, b);
}

View File

@ -58,9 +58,9 @@ class Navigation : public Spatial {
return (a.key == p_key.a.key) ? (b.key < p_key.b.key) : (a.key < p_key.a.key);
};
EdgeKey(const Point &p_a = Point(), const Point &p_b = Point()) {
a = p_a;
b = p_b;
EdgeKey(const Point &p_a = Point(), const Point &p_b = Point())
: a(p_a),
b(p_b) {
if (a.key > b.key) {
SWAP(a, b);
}