[Commits] [wesnoth/wesnoth] 4d7303: add operators == (attribute_value, std::string)

GitHub noreply at github.com
Fri Jun 27 20:33:42 UTC 2014


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 4d73031680b8889ec70e42607016269f7c421da5
      https://github.com/wesnoth/wesnoth/commit/4d73031680b8889ec70e42607016269f7c421da5
  Author: gfgtdf <f492343 at rmqkr.net>
  Date:   2014-06-27 (Fri, 27 Jun 2014)

  Changed paths:
    M src/config.cpp
    M src/config.hpp

  Log Message:
  -----------
  add operators == (attribute_value, std::string)


  Commit: 8d8248f369f03fdc8038c26944ca5f80ca5f6d85
      https://github.com/wesnoth/wesnoth/commit/8d8248f369f03fdc8038c26944ca5f80ca5f6d85
  Author: gfgtdf <f492343 at rmqkr.net>
  Date:   2014-06-27 (Fri, 27 Jun 2014)

  Changed paths:
    M src/config.hpp

  Log Message:
  -----------
  fixup 'add operators == (attribute_value, std::string)'

we need to keep the code form using these functions in case of c["a"] ==
0


  Commit: 852b6981329a96055249c513477be0d43b2fcaa0
      https://github.com/wesnoth/wesnoth/commit/852b6981329a96055249c513477be0d43b2fcaa0
  Author: gfgtdf <f492343 at rmqkr.net>
  Date:   2014-06-27 (Fri, 27 Jun 2014)

  Changed paths:
    M src/config.hpp

  Log Message:
  -----------
  add operators !=(attribute_value, std::string)


  Commit: 484d926c301044711215044adb9c63be3b692da6
      https://github.com/wesnoth/wesnoth/commit/484d926c301044711215044adb9c63be3b692da6
  Author: gfgtdf <f492343 at rmqkr.net>
  Date:   2014-06-27 (Fri, 27 Jun 2014)

  Changed paths:
    M src/generators/map_create.cpp
    M src/help.cpp
    M src/multiplayer_wait.cpp
    M src/saved_game.cpp

  Log Message:
  -----------
  fixup use of operator !=(attribute_value, const char*)

since we don't use t_string's == operator anymore in this case, c["a"]
!= "" will evaluate to true in case of "a" beeing not existent. To get
the desired behaviour we need to use the .empty() method.

I also add an assert in map_generation for a possible segfault that i
noticed during fixing this.


  Commit: 606becd24be1b5a04c30377fe4751f1c77159309
      https://github.com/wesnoth/wesnoth/commit/606becd24be1b5a04c30377fe4751f1c77159309
  Author: gfgtdf <f492343 at rmqkr.net>
  Date:   2014-06-27 (Fri, 27 Jun 2014)

  Changed paths:
    M src/unit.cpp
    M src/unit_types.cpp

  Log Message:
  -----------
  fix unit(_type)::resistance_filter_matches

fix use of operator == (atribute_value, char*)


  Commit: 5089669eb95c8a0fd31f8fbe4dff584885c259b4
      https://github.com/wesnoth/wesnoth/commit/5089669eb95c8a0fd31f8fbe4dff584885c259b4
  Author: gfgtdf <f492343 at rmqkr.net>
  Date:   2014-06-27 (Fri, 27 Jun 2014)

  Changed paths:
    M src/tests/test_config.cpp

  Log Message:
  -----------
  extend attibute_value unit test


  Commit: ea61f1759bb7e7b7205a1e2e63b4b06ccd32308c
      https://github.com/wesnoth/wesnoth/commit/ea61f1759bb7e7b7205a1e2e63b4b06ccd32308c
  Author: gfgtdf <tischpapier at gmail.com>
  Date:   2014-06-27 (Fri, 27 Jun 2014)

  Changed paths:
    M src/config.cpp
    M src/config.hpp
    M src/generators/map_create.cpp
    M src/help.cpp
    M src/multiplayer_wait.cpp
    M src/saved_game.cpp
    M src/tests/test_config.cpp
    M src/unit.cpp
    M src/unit_types.cpp

  Log Message:
  -----------
  Merge pull request #226 from gfgtdf/config_comparision

add operators ==,!= (attribute_value, std::string)

previously comparisions like c["a"] = "b" were evaluated by 
inline bool operator==(const std::string &a, const t_string &b) 
by casting atribute_value to std::string, and const char * to t_string

we fix this by adding explicit equality operator for these cases.

Not creating t_string also results in significant preformance improvements in some cases.


Compare: https://github.com/wesnoth/wesnoth/compare/cb5a9a0d28ed...ea61f1759bb7


More information about the Commits mailing list