[Commits] [wesnoth/wesnoth] 5eee20: clean up instances of std::copy

GitHub noreply at github.com
Fri Mar 21 09:46:05 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 5eee20be97ad5470c7faaec18f0cacd21a543566
      https://github.com/wesnoth/wesnoth/commit/5eee20be97ad5470c7faaec18f0cacd21a543566
  Author: Nathan Walker <nathan.b.walker at vanderbilt.edu>
  Date:   2014-03-19 (Wed, 19 Mar 2014)

  Changed paths:
    M src/ai/testing/ca.cpp
    M src/ai/testing/ca_testing_recruitment.cpp
    M src/config_cache.cpp
    M src/game_preferences.cpp
    M src/help.cpp
    M src/multiplayer_create.cpp
    M src/pathfind/astarsearch.cpp
    M src/sdl_utils.cpp
    M src/terrain_filter.cpp
    M src/tod_manager.cpp
    M src/unit_map.cpp
    M src/whiteboard/side_actions.cpp
    M src/widgets/textbox.cpp

  Log Message:
  -----------
  clean up instances of std::copy

In many places, std::copy was used with back_inserters, or other
std::inserters. These have in most cases been replaced by using the
ranged insert member function of each stl container. Firstly, this makes more
readable code. Also, this is often more efficient because,
if the compiler can find the distance between the source iterators,
it only has to make one block allocation and then fill it
with values. In other cases, containers were being default constructed
and then std::copy'd into with some form of inserter. These were cleaned up
by using the iterator range constructor instead.
Use of std::copy was especially egregious in the case of associative
containers such as map and set. Sometimes back_inserter was
being used, other times std::inserter set at front, but it doesn't matter
because there is no front or back when inserting, and it's much cleaner
to just use set or map::insert(iterator begin, iterator end).


  Commit: efec4735ed574fba1a541c3cf9bcc9db38fb04a1
      https://github.com/wesnoth/wesnoth/commit/efec4735ed574fba1a541c3cf9bcc9db38fb04a1
  Author: Nathan Walker <nathan.b.walker at vanderbilt.edu>
  Date:   2014-03-19 (Wed, 19 Mar 2014)

  Changed paths:
    M src/config_cache.cpp
    M src/game_preferences.cpp
    M src/help.cpp
    M src/multiplayer_create.cpp
    M src/sdl_utils.cpp
    M src/terrain_filter.cpp

  Log Message:
  -----------
  (cosmetic) fix code tabs

Codeblocks made some of my tabs into spaces and I had to fix it.
Also, forgot to mention this before, but I cleaned up some of the code
for astarsearch.cpp as well.


  Commit: 923519d75ad30debefa683b3567ee9448f6396b0
      https://github.com/wesnoth/wesnoth/commit/923519d75ad30debefa683b3567ee9448f6396b0
  Author: Nathan Walker <nathan.b.walker at vanderbilt.edu>
  Date:   2014-03-19 (Wed, 19 Mar 2014)

  Changed paths:
    M src/config.cpp

  Log Message:
  -----------
  Change config assignment op to copy-and-swap

The previous implementation was not strongly exception safe.
This code is nearly identical logically, but with strong exception safety.
It's also good practice and more readable.


  Commit: eb48917ce56f7cd5453131124f3dc3cea792b2c7
      https://github.com/wesnoth/wesnoth/commit/eb48917ce56f7cd5453131124f3dc3cea792b2c7
  Author: lipk <lipkab at zoho.com>
  Date:   2014-03-21 (Fri, 21 Mar 2014)

  Changed paths:
    M src/ai/testing/ca.cpp
    M src/ai/testing/ca_testing_recruitment.cpp
    M src/config.cpp
    M src/config_cache.cpp
    M src/game_preferences.cpp
    M src/help.cpp
    M src/multiplayer_create.cpp
    M src/pathfind/astarsearch.cpp
    M src/terrain_filter.cpp
    M src/tod_manager.cpp
    M src/unit_map.cpp
    M src/whiteboard/side_actions.cpp
    M src/widgets/textbox.cpp

  Log Message:
  -----------
  Merge pull request #122 from Rift-Walker/config_edits

Config edits


Compare: https://github.com/wesnoth/wesnoth/compare/d21988165601...eb48917ce56f


More information about the Commits mailing list