[wesnoth-commits] [wesnoth/wesnoth] 580f96: small unit::xp_color() optimisation

gfgtdf noreply at github.com
Wed Feb 12 04:29:44 UTC 2020


  Branch: refs/heads/master
  Home:   https://github.com/wesnoth/wesnoth
  Commit: 580f96336477f80a11c219c93749a110a8cf9bff
      https://github.com/wesnoth/wesnoth/commit/580f96336477f80a11c219c93749a110a8cf9bff
  Author: gfgtdf <daniel.gfgtdf at gmail.com>
  Date:   2020-02-12 (Wed, 12 Feb 2020)

  Changed paths:
    M src/units/unit.cpp

  Log Message:
  -----------
  small unit::xp_color() optimisation

We now call get_modification_advances() once (instead of twice). In particular get_modification_advances() can be a rather slow operation for a unit that has many [advancement]s. and xp_color() is called rather often from the drawing code.

In fact xp_color() has caused annoying slowdowns in the past for a certain umc campaign that adds many dummy ( this means: blocked via require_amla by default) [advancement]s to units types. (this was also the reason for https://github.com/wesnoth/wesnoth/commit/4d73031680b8889ec70e42607016269f7c421da5 where i found that a lot of temporary t_string objects were created during xp_color/get_modification_advances while investigating that). (that was before the second call to get_modification_advances() was added but well, better to call it once than twice if we know that calling it once was already problem in the past, i even considered caching he result of get_modification_advances() in the past but i currently don't think that's needed anymore, in particular since umc authors have now better options that addong tons of dummy [advamcent]s to unit_types)





More information about the Commits mailing list