13 Commits

Author SHA1 Message Date
John Bytheway e95a4fc9b8 Promote string_id constants to global statics
Our string_id constants were a mixture of temporaries, locals, and
globals.  Pull them all out as globals, for consistency and efficiency.
The efficiency comes from the fact that each string_id instance caches
its respective int_id, and sharing one instance means that value need
not be recomputed.
2021-11-19 19:10:09 -05:00
John Bytheway 8cc6378fc5 clang-tidy modernize-use-emplace (#48661)
* Port code to emplace_back

This is clang-tidy making automated changes to convert push_back into
emplace_back whenever the argument to push_back is either a constructor
call for the type in question of an expression of a type implicitly
convertible to the type in question.

This should eliminate one move-construction of the inserted object for
each call.

* Enable clang-tidy modernize-use-emplace
2021-07-03 07:42:06 -07:00
John Bytheway ebd549b300 Fix StringMaker ODR violations in tests
Catch2 provides a customization point for converting our types to
strings by specializing the StringMaker template.

We have some specializations in stringmaker.h, but this feature was only
working intermittently.  I finally figured out that was due to an ODR
violation.  The test files that didn't include stringmaker.h were
compiling a different specialization than the ones that did.

Re-jig the test includes so that any file including catch.hpp also
includes stringmaker.h, thereby ensuring that the custom
specializations are used everywhere and there is no ODR violation.

I achieved this by adding a new cata_catch.h header and making all
existing headers include catch.hpp via the new header.
2021-07-03 07:42:06 -07:00
John Bytheway 0680a7c3ad Enable performance-inefficient-vector-operation (#48480)
* Add a collection of `vector::reserve` calls.

All changes done automatically by clang-tidy.

* Enable performance-inefficient-vector-operation
2021-07-03 07:42:05 -07:00
Binrui Dong 9fdb7ef59c Run IWYU
* Change _ctype.h and __locale to cctype and clocale

* Change _wctype.h to cwctype in game.cpp

* Change __functional_base to functional

* Remove libcxx internal headers

* Remove UNIX system headers

* Fix clang-tidy error with -nostdinc++
2021-02-06 00:18:41 -05:00
Aivean 8176f28447 get rid of int_id<json_flag>
alias flag_id to flag_str_id (for now)
2020-11-08 14:07:37 -08:00
Ivan Zaitsev ee0a92cae2 Add a specialization for static/interned string_ids (performance improved ≈30%) (#45099)
* add a specialization for static/interned string_ids
make most of the string_id interned

* extract sorted_lex into a separate header to keep string_id.h lightweight

* apply suggestions from review:
* remove `abstract_string_id_params`
* std::binary_function
* replace std::enable_if -> std::enable_if_t where appropriate
* same with std::conditional -> std::conditional_t
* change collection names in string_id.cpp

* replace `insert` with `emplace`
2020-10-29 17:51:02 -07:00
ZhilkinSerg 8de4306844 Fix MSVC builds (#45103) 2020-10-27 16:05:19 -07:00
Aivean dcd0072720 attempt to make clang 3.8 happy:
"error: reference to local variable 'bit_flags_size' declared in enclosing function"
2020-10-19 16:32:30 -07:00
Aivean c32a629ceb replace all item flag constants with static string_ids
remove adapter has_flag (and related) methods that took string argument
change all remaining method signatures where item flags were passed as strings
2020-10-18 19:56:40 -07:00
Aivean 91af4a8f69 introduce generic_factory version wrapper that allows to create caches that are invalidated together with corresponding generic_factory
use the new versioned cache to optimize performance of materials::get_rotting
2020-10-01 11:08:24 -07:00
Ivan Zaitsev 35a2d9e465 Follow up to #44261: string_id performance and correctness (#44398)
* implement suggested changes from #44261
improve string_id comparison performance when `_version`s match
add catch2 benchmarks and unit tests for string_id

* apply suggestions from review
enable `CATCH_CONFIG_ENABLE_BENCHMARKING` permanently
disable benchmark tests on one-by-one basis by default

* Enable benchmarking in VS project
2020-09-25 10:18:54 +03:00
Aivean 3d2aabd636 improve performance of cached string ids
make string_id behavior correct regardless of whether it's core or mod
add generic_factory test
2020-09-20 03:17:36 +00:00