[Commits] [wesnoth/wesnoth] deee52: Added condition to define HAVE_CXX17 macro

GitHub noreply at github.com
Sun Jan 21 02:55:45 UTC 2018


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: deee52ce19e953e2052ca8e6407430b10bae54a1
      https://github.com/wesnoth/wesnoth/commit/deee52ce19e953e2052ca8e6407430b10bae54a1
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2018-01-21 (Sun, 21 Jan 2018)

  Changed paths:
    M src/global.hpp

  Log Message:
  -----------
  Added condition to define HAVE_CXX17 macro


  Commit: ba5ddc4bcbc18e88dfb2f8d6a8c82c8276238d40
      https://github.com/wesnoth/wesnoth/commit/ba5ddc4bcbc18e88dfb2f8d6a8c82c8276238d40
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2018-01-21 (Sun, 21 Jan 2018)

  Changed paths:
    M src/utils/general.hpp

  Log Message:
  -----------
  Use std::clamp with C++17


  Commit: eb52503934b65ee1a434c4055a42b4d2ff18b370
      https://github.com/wesnoth/wesnoth/commit/eb52503934b65ee1a434c4055a42b4d2ff18b370
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2018-01-21 (Sun, 21 Jan 2018)

  Changed paths:
    M src/buffered_istream.hpp
    M src/serialization/tokenizer.hpp
    M src/utils/general.hpp

  Log Message:
  -----------
  Remove use of __builtin_expect when building with GCC

__builtin_expect is something that should only be used if you're very sure it will result in
an optimization (see http://blog.man7.org/2012/10/how-much-do-builtinexpect-likely-and.html).

This code was added back in 2008. It seems it was part of an effort to get the preprocessor
functioning faster. It looks like mordante played some role in the decision of where to use
the LIKELY and UNLIKELY macros, so it's possible it had some use at the time (he's a rather
experienced programmer).

However, it's better to let the compiler automatically optimize code itself. I haven't done
any profiling on the preprocessor speed with or without __builtin_expect, but it doesn't seem
worth keeping this around and having to test every so often whether it's still useful or has
become a performance hit instead.

It's also worth noting that I myself noticed what seems a perceptible performance improvement
in the game (again, not backed by profiling) when I switched from TDM GCC to MSVC 2017. IIRC,
I'm using at least quick LTO for my builds. Apples and oranges, yes, but it also proves there
are likely various compiler options (such as LTO) which could improve performance on their own,
and better, than trying to point the program down branch paths ourselves.


  Commit: d3e2ab9d22b45a07ba6a052a74ba8ea0870829c4
      https://github.com/wesnoth/wesnoth/commit/d3e2ab9d22b45a07ba6a052a74ba8ea0870829c4
  Author: Charles Dang <exodia339 at gmail.com>
  Date:   2018-01-21 (Sun, 21 Jan 2018)

  Changed paths:
    M src/utils/general.hpp

  Log Message:
  -----------
  Formatting cleanup of utils::contains impl

Makes this bit much easier to read.


Compare: https://github.com/wesnoth/wesnoth/compare/220ac5f276c9...d3e2ab9d22b4


More information about the Commits mailing list