[Commits] [wesnoth/wesnoth] 1a03d3: Main: formatting cleanup

GitHub noreply at github.com
Thu Dec 7 08:19:49 UTC 2017


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 1a03d3ac63b1795756060d064108e3fb6a168f02
      https://github.com/wesnoth/wesnoth/commit/1a03d3ac63b1795756060d064108e3fb6a168f02
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-12-06 (Wed, 06 Dec 2017)

  Changed paths:
    M src/wesnoth.cpp

  Log Message:
  -----------
  Main: formatting cleanup


  Commit: 983c5de05a867b1b69dc1aa44dfd54100091c01e
      https://github.com/wesnoth/wesnoth/commit/983c5de05a867b1b69dc1aa44dfd54100091c01e
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-12-07 (Thu, 07 Dec 2017)

  Changed paths:
    M src/wesnoth.cpp

  Log Message:
  -----------
  Main: range-for


  Commit: 590501aa1ec398e2a98bf94a5c0de0fc380851f6
      https://github.com/wesnoth/wesnoth/commit/590501aa1ec398e2a98bf94a5c0de0fc380851f6
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-12-07 (Thu, 07 Dec 2017)

  Changed paths:
    M src/gui/widgets/styled_widget.cpp

  Log Message:
  -----------
  GUI2/Styled Widget: cleaned up get_best_text_size

* Removed unnecessary initial value of `size`.
* Added an explanatory comment on use of text renderer.
* Improved log output.


  Commit: dfa09cd9d9be44ca036e6a506bdcd3116862b37e
      https://github.com/wesnoth/wesnoth/commit/dfa09cd9d9be44ca036e6a506bdcd3116862b37e
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-12-07 (Thu, 07 Dec 2017)

  Changed paths:
    M src/gui/core/canvas.cpp
    M src/gui/core/canvas.hpp
    M src/gui/core/widget_definition.cpp
    M src/gui/core/widget_definition.hpp
    M src/gui/widgets/styled_widget.cpp
    M src/gui/widgets/styled_widget.hpp

  Log Message:
  -----------
  GUI2: refactored styled_widget canvas initialization process

Back in 515f450432cda01d4c I attempted to optimize this, but I didn't do it right. Since I didn't
define a move ctor for canvas, that std::move call was useless and the copy ctor was being called
anyway. Though, that change wasn't a total waste. It still reduced the number of canvases created
from (I think) 3 to 2, since the code was no longer going default-construction
and copy-assignment from the state struct.

These new changes completely remove the canvas object from the state struct. Nothing particularity
special was being done there, only a call to canvas::set_cfg. Instead, the canvas config is saved
in the state objects and then styled_widget initializes the canvas itself. This does mean there's
config copying going on here, sadly, but it's unavoidable given the current design.

This also removes the definition_load_configuration function from styled_widget. Its contents were
moved to the ctor. This ensures only the exact number of canvas objects needed are created. No
copying from the state objects, no reallocations. This also means we can delete the copy ctor (see
below).

A move ctor was added to canvas (though it admittedly isn't needed now since no canvas moving
occurs), and the copy ctor deleted.


  Commit: 33f70ea32c1af8ac2919469e1d807a3ed127336b
      https://github.com/wesnoth/wesnoth/commit/33f70ea32c1af8ac2919469e1d807a3ed127336b
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2017-12-07 (Thu, 07 Dec 2017)

  Changed paths:
    M src/gui/core/widget_definition.hpp

  Log Message:
  -----------
  GUI2: removed unused cast helper

std::static_pointer_cast or styled_widget::cast_config_to can be used instead.


Compare: https://github.com/wesnoth/wesnoth/compare/aa94db4d0fbc...33f70ea32c1a


More information about the Commits mailing list