Commit Graph

34 Commits

Author SHA1 Message Date
29f75ad5fa Remove unused StringName::search. 2025-06-11 00:16:51 +02:00
579feb387c Core: Add [[nodiscard]] to string-like classes 2025-05-06 12:23:41 -05:00
91362a61da Simplify StringName to bool conversions.
Move `mutex` include of `string_name.h` to `string_name.cpp`.
2025-04-30 16:59:34 +02:00
e57427900f Use BinaryMutex instead of Mutex for StringName. 2025-04-28 17:13:26 +02:00
3b31636985 Remove unnecessary StringName idx cache in _Data to reduce its size by 4 bytes.
Encapsulate `StringName` details in its cpp file.
2025-04-25 19:22:29 +02:00
91fe434a86 Always use String as StringName backing internally. 2025-04-23 14:57:03 +02:00
e989d7bd89 Change StringName.operator const void * to explicit operator bool. 2025-04-11 18:34:01 +02:00
fdbf6ecc9f Merge pull request #98408 from rune-scape/stringlikevariantorder-in-place
StringLikeVariantOrder: Compare in-place
2025-03-18 14:42:58 -05:00
0c7d78f455 StringLikeVariantOrder: Compare in-place 2025-03-18 11:21:30 -07:00
b28d6d1fa3 Don't inline certain functions for smaller binary size.
Co-authored-by: Thaddeus Crews <repiteo@outlook.com>
2025-03-18 21:40:25 +08:00
4320800621 Core: Expand is_zero_constructible coverage 2025-03-17 11:45:26 -05:00
324512e11c Style: Replace header guards with #pragma once 2025-03-07 17:33:47 -06:00
8c4e674770 Add move semantics (constructor, assignment) to StringName. 2024-12-16 19:02:52 +01:00
a47d29cf11 Move StringName != to the header file to make it inlineable. 2024-12-01 19:50:34 +01:00
0dde931bc9 StringName: Fix empty hash
+Fixed compat hashes
2024-09-09 13:30:02 -07:00
6abd17265b StringName: operator== compares in-place 2024-09-03 17:31:08 -07:00
723878bbab StringName: Use inline static field definitions
Before this change StringName used regular static field
definitions for its mutex, _table, configured and debug_stringname
fields.

Since in the general case the ordering of the static variable and field
initialization and destruction is undefined, it was possible that
the destruction of StringName's static fields happened prior to
the destruction of statically allocated StringName instances.

By changing the static field definitions to inline in string_name.h,
the C++17 standard guarantees the correct initialization and destruction
ordering.
2024-07-24 02:40:36 +02:00
d2003d2025 Remove _HashUnion from StringName 2024-02-14 15:38:57 -05:00
d2ddd8b228 Fix StringName comparison 2023-05-18 13:25:40 +02:00
8950943356 Optimize Object::get_class_name
* Run the static function once per class instead of one per instance.
* Saves some memory in Object derived classes.
2023-04-08 19:25:50 +02:00
d95794ec8a One Copyright Update to rule them all
As many open source projects have started doing it, we're removing the
current year from the copyright notice, so that we don't need to bump
it every year.

It seems like only the first year of publication is technically
relevant for copyright notices, and even that seems to be something
that many companies stopped listing altogether (in a version controlled
codebase, the commits are a much better source of date of publication
than a hardcoded copyright statement).

We also now list Godot Engine contributors first as we're collectively
the current maintainers of the project, and we clarify that the
"exclusive" copyright of the co-founders covers the timespan before
opensourcing (their further contributions are included as part of Godot
Engine contributors).

Also fixed "cf." Frenchism - it's meant as "refer to / see".
2023-01-05 13:25:55 +01:00
522d4243bf Add missing != operator to StringName 2022-12-20 17:25:54 +03:00
8580f377a3 Implement Scene Unique Nodes
Implements https://github.com/godotengine/godot-proposals/issues/4096

* Nodes can be marked unique to the scene in the editor (or via code).
* Unique nodes can be accessed via the **%** prefix at any point in the path. From that point in the path (depending on whether the scene of the path is), the unique node will be fetched.
* Implementation is very optimal, as these nodes are cached.
2022-04-25 12:19:17 +02:00
f8ab79e68a Zero initialize all pointer class and struct members
This prevents the pitfall of UB when checking if they have been
assigned something valid by comparing to nullptr.
2022-04-04 19:49:50 +02:00
1bdb82c64e Fix typos with codespell
Using codespell 2.2-dev from current git.

Added `misc/scripts/codespell.sh` to make it easier to run it once in a
while and update the skip and ignore lists.
2022-02-10 12:30:19 +01:00
38232c70db Clarify SNAME usage
* Explain where it should be used, with examples.
* Clarify that it should _not_ be used everywhere, only where needed.
* Supersedes #57720

This PR is the result of the discussion that happened in a contractor meeting, and it attempts to clarify the intended use for this macro for other contributors.
As a personal note, It is my view that other approaches to using SNAME (like having a global or per class table of string names) are mere overengineering without any real benefit (performance remains the same, and usage of stringnames becomes more cumbersome. Additionally, there was not any significant amount of errors in name mismatching as a result of using strings since Godot was open sourced).
2022-02-08 09:21:10 +01:00
fe52458154 Update copyright statements to 2022
Happy new year to the wonderful Godot community!
2022-01-03 21:27:34 +01:00
cee905f04f Adds ability to debug stringnames
* References (which include hash tables) can be profiled with --debug-stringnames
2021-07-20 17:31:51 -03:00
a6adb58493 Editor StringName and Viewport optimizations
* Added explicit return type to the SNAME macro.
* Add some extra SNAME usages.
* Change some ClassDB methods to use const StringName & arguments.
* Cache the Window parent in Control because it's used in
  is_layout_rtl(), which is called often.
* Only enable internal processing for viewports that need it.
* Change CanvasItem::group to be a StringName because it's only used as
  that.
2021-07-20 20:35:41 +02:00
6631f66c2a Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname.
* Subsequent usages use the cached version.
* Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time.
* Replaced all theme usages by this new macro.
* Replace all signal emission usages by this new macro.
* Replace all call_deferred usages by this new macro.

This is part of ongoing work to optimize GUI and the editor.
2021-07-18 21:20:02 -03:00
b5334d14f7 Update copyright statements to 2021
Happy new year to the wonderful Godot community!

2020 has been a tough year for most of us personally, but a good year for
Godot development nonetheless with a huge amount of work done towards Godot
4.0 and great improvements backported to the long-lived 3.2 branch.

We've had close to 400 contributors to engine code this year, authoring near
7,000 commit! (And that's only for the `master` branch and for the engine code,
there's a lot more when counting docs, demos and other first-party repos.)

Here's to a great year 2021 for all Godot users 🎆
2021-01-01 20:19:21 +01:00
5b937d493f Rename empty() to is_empty() 2020-12-28 10:39:56 +00:00
02161aad5a Remove empty lines around braces with the formatting script 2020-11-16 23:38:11 -05:00
127458ed17 Reorganized core/ directory, it was too fatty already
-Removed FuncRef, since Callable makes it obsolete
-Removed int_types.h as its obsolete in c++11+
-Changed color names code
2020-11-07 20:17:12 -03:00