summaryrefslogtreecommitdiff
path: root/src/guiFormSpecMenu.h
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-04-21 10:06:08 +0200
committerGitHub <noreply@github.com>2017-04-21 10:06:08 +0200
commit370354cc87937bbfb6f24aa062966af8e039cec0 (patch)
treee0400c3b3c63d3e8e8b22c81e40a9cabe2d1b5b1 /src/guiFormSpecMenu.h
parentde5ecc9fa31d557e2d0ca638b1c98435707046b9 (diff)
downloadminetest-370354cc87937bbfb6f24aa062966af8e039cec0.tar.gz
minetest-370354cc87937bbfb6f24aa062966af8e039cec0.tar.bz2
minetest-370354cc87937bbfb6f24aa062966af8e039cec0.zip
Fix various performance issues reported by cppcheck (#5628)
* Also remove 1 non declared but defined functions
Diffstat (limited to 'src/guiFormSpecMenu.h')
-rw-r--r--src/guiFormSpecMenu.h65
1 files changed, 27 insertions, 38 deletions
diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h
index 4bc2448d8..ec122b617 100644
--- a/src/guiFormSpecMenu.h
+++ b/src/guiFormSpecMenu.h
@@ -78,22 +78,19 @@ class GUIFormSpecMenu : public GUIModalMenu
{
struct ItemSpec
{
- ItemSpec()
- {
- i = -1;
- }
+ ItemSpec() :
+ i(-1)
+ {}
+
ItemSpec(const InventoryLocation &a_inventoryloc,
const std::string &a_listname,
- s32 a_i)
- {
- inventoryloc = a_inventoryloc;
- listname = a_listname;
- i = a_i;
- }
- bool isValid() const
- {
- return i != -1;
- }
+ s32 a_i) :
+ inventoryloc(a_inventoryloc),
+ listname(a_listname),
+ i(a_i)
+ {}
+
+ bool isValid() const { return i != -1; }
InventoryLocation inventoryloc;
std::string listname;
@@ -208,14 +205,13 @@ class GUIFormSpecMenu : public GUIModalMenu
const std::wstring &default_text, int id) :
fname(name),
flabel(label),
+ fdefault(unescape_enriched(default_text)),
fid(id),
send(false),
ftype(f_Unknown),
is_exit(false)
- {
- //flabel = unescape_enriched(label);
- fdefault = unescape_enriched(default_text);
- }
+ {}
+
std::string fname;
std::wstring flabel;
std::wstring fdefault;
@@ -239,17 +235,14 @@ class GUIFormSpecMenu : public GUIModalMenu
};
struct TooltipSpec {
- TooltipSpec()
- {
- }
+ TooltipSpec() {}
TooltipSpec(std::string a_tooltip, irr::video::SColor a_bgcolor,
irr::video::SColor a_color):
+ tooltip(utf8_to_wide(a_tooltip)),
bgcolor(a_bgcolor),
color(a_color)
- {
- //tooltip = unescape_enriched(utf8_to_wide(a_tooltip));
- tooltip = utf8_to_wide(a_tooltip);
- }
+ {}
+
std::wstring tooltip;
irr::video::SColor bgcolor;
irr::video::SColor color;
@@ -271,12 +264,11 @@ class GUIFormSpecMenu : public GUIModalMenu
StaticTextSpec(const std::wstring &a_text,
const core::rect<s32> &a_rect,
gui::IGUIButton *a_parent_button):
+ text(a_text),
rect(a_rect),
parent_button(a_parent_button)
- {
- //text = unescape_enriched(a_text);
- text = a_text;
- }
+ {}
+
std::wstring text;
core::rect<s32> rect;
gui::IGUIButton *parent_button;
@@ -550,22 +542,19 @@ private:
class FormspecFormSource: public IFormSource
{
public:
- FormspecFormSource(const std::string &formspec)
- {
- m_formspec = formspec;
- }
+ FormspecFormSource(const std::string &formspec):
+ m_formspec(formspec)
+ {}
~FormspecFormSource()
{}
- void setForm(const std::string &formspec) {
+ void setForm(const std::string &formspec)
+ {
m_formspec = FORMSPEC_VERSION_STRING + formspec;
}
- std::string getForm()
- {
- return m_formspec;
- }
+ std::string getForm() { return m_formspec; }
std::string m_formspec;
};