diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-03-23 00:12:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-23 00:12:12 +0100 |
commit | 6a84ade31693e0bbffe21e66edfd16c0af1b83c1 (patch) | |
tree | a1114a1d610e624b06202438879282f9a740d55a /core | |
parent | 6fa24729ae82194fdc6453c3e5b958f8b6f356b0 (diff) | |
parent | 07f1cd5ff8e1f27416fee248738678df24dd823a (diff) |
Merge pull request #45234 from madmiraal/rename-phashtranslation
Rename PHashTranslation to OptimizedTranslation
Diffstat (limited to 'core')
-rw-r--r-- | core/register_core_types.cpp | 4 | ||||
-rw-r--r-- | core/string/optimized_translation.cpp (renamed from core/string/compressed_translation.cpp) | 30 | ||||
-rw-r--r-- | core/string/optimized_translation.h (renamed from core/string/compressed_translation.h) | 14 | ||||
-rw-r--r-- | core/string/translation_po.cpp | 2 |
4 files changed, 25 insertions, 25 deletions
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index b58abc81d1..d6a5eff10d 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -68,7 +68,7 @@ #include "core/object/class_db.h" #include "core/object/undo_redo.h" #include "core/os/main_loop.h" -#include "core/string/compressed_translation.h" +#include "core/string/optimized_translation.h" #include "core/string/translation.h" static Ref<ResourceFormatSaverBinary> resource_saver_binary; @@ -183,7 +183,7 @@ void register_core_types() { ClassDB::register_class<MultiplayerAPI>(); ClassDB::register_class<MainLoop>(); ClassDB::register_class<Translation>(); - ClassDB::register_class<PHashTranslation>(); + ClassDB::register_class<OptimizedTranslation>(); ClassDB::register_class<UndoRedo>(); ClassDB::register_class<HTTPClient>(); ClassDB::register_class<TriangleMesh>(); diff --git a/core/string/compressed_translation.cpp b/core/string/optimized_translation.cpp index 15abf63f7e..53d0a8924d 100644 --- a/core/string/compressed_translation.cpp +++ b/core/string/optimized_translation.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* compressed_translation.cpp */ +/* optimized_translation.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "compressed_translation.h" +#include "optimized_translation.h" #include "core/templates/pair.h" @@ -36,13 +36,13 @@ extern "C" { #include "thirdparty/misc/smaz.h" } -struct _PHashTranslationCmp { +struct CompressedString { int orig_len; CharString compressed; int offset; }; -void PHashTranslation::generate(const Ref<Translation> &p_from) { +void OptimizedTranslation::generate(const Ref<Translation> &p_from) { // This method compresses a Translation instance. // Right now, it doesn't handle context or plurals, so Translation subclasses using plurals or context (i.e TranslationPO) shouldn't be compressed. #ifdef TOOLS_ENABLED @@ -54,7 +54,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) { Vector<Vector<Pair<int, CharString>>> buckets; Vector<Map<uint32_t, int>> table; Vector<uint32_t> hfunc_table; - Vector<_PHashTranslationCmp> compressed; + Vector<CompressedString> compressed; table.resize(size); hfunc_table.resize(size); @@ -76,7 +76,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) { //compress string CharString src_s = p_from->get_message(E->get()).operator String().utf8(); - _PHashTranslationCmp ps; + CompressedString ps; ps.orig_len = src_s.size(); ps.offset = total_compression_size; @@ -182,7 +182,7 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) { #endif } -bool PHashTranslation::_set(const StringName &p_name, const Variant &p_value) { +bool OptimizedTranslation::_set(const StringName &p_name, const Variant &p_value) { String name = p_name.operator String(); if (name == "hash_table") { hash_table = p_value; @@ -199,7 +199,7 @@ bool PHashTranslation::_set(const StringName &p_name, const Variant &p_value) { return true; } -bool PHashTranslation::_get(const StringName &p_name, Variant &r_ret) const { +bool OptimizedTranslation::_get(const StringName &p_name, Variant &r_ret) const { String name = p_name.operator String(); if (name == "hash_table") { r_ret = hash_table; @@ -214,8 +214,8 @@ bool PHashTranslation::_get(const StringName &p_name, Variant &r_ret) const { return true; } -StringName PHashTranslation::get_message(const StringName &p_src_text, const StringName &p_context) const { - // p_context passed in is ignore. The use of context is not yet supported in PHashTranslation. +StringName OptimizedTranslation::get_message(const StringName &p_src_text, const StringName &p_context) const { + // p_context passed in is ignore. The use of context is not yet supported in OptimizedTranslation. int htsize = hash_table.size(); @@ -271,18 +271,18 @@ StringName PHashTranslation::get_message(const StringName &p_src_text, const Str } } -StringName PHashTranslation::get_plural_message(const StringName &p_src_text, const StringName &p_plural_text, int p_n, const StringName &p_context) const { - // The use of plurals translation is not yet supported in PHashTranslation. +StringName OptimizedTranslation::get_plural_message(const StringName &p_src_text, const StringName &p_plural_text, int p_n, const StringName &p_context) const { + // The use of plurals translation is not yet supported in OptimizedTranslation. return get_message(p_src_text, p_context); } -void PHashTranslation::_get_property_list(List<PropertyInfo> *p_list) const { +void OptimizedTranslation::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "hash_table")); p_list->push_back(PropertyInfo(Variant::PACKED_INT32_ARRAY, "bucket_table")); p_list->push_back(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "strings")); p_list->push_back(PropertyInfo(Variant::OBJECT, "load_from", PROPERTY_HINT_RESOURCE_TYPE, "Translation", PROPERTY_USAGE_EDITOR)); } -void PHashTranslation::_bind_methods() { - ClassDB::bind_method(D_METHOD("generate", "from"), &PHashTranslation::generate); +void OptimizedTranslation::_bind_methods() { + ClassDB::bind_method(D_METHOD("generate", "from"), &OptimizedTranslation::generate); } diff --git a/core/string/compressed_translation.h b/core/string/optimized_translation.h index 0abb770178..bccf932383 100644 --- a/core/string/compressed_translation.h +++ b/core/string/optimized_translation.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* compressed_translation.h */ +/* optimized_translation.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -28,13 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef COMPRESSED_TRANSLATION_H -#define COMPRESSED_TRANSLATION_H +#ifndef OPTIMIZED_TRANSLATION_H +#define OPTIMIZED_TRANSLATION_H #include "core/string/translation.h" -class PHashTranslation : public Translation { - GDCLASS(PHashTranslation, Translation); +class OptimizedTranslation : public Translation { + GDCLASS(OptimizedTranslation, Translation); //this translation uses a sort of modified perfect hash algorithm //it requires hashing strings twice and then does a binary search, @@ -83,7 +83,7 @@ public: virtual StringName get_plural_message(const StringName &p_src_text, const StringName &p_plural_text, int p_n, const StringName &p_context = "") const override; void generate(const Ref<Translation> &p_from); - PHashTranslation() {} + OptimizedTranslation() {} }; -#endif // COMPRESSED_TRANSLATION_H +#endif // OPTIMIZED_TRANSLATION_H diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp index 42ba30fbe5..2efadaa9b7 100644 --- a/core/string/translation_po.cpp +++ b/core/string/translation_po.cpp @@ -275,7 +275,7 @@ void TranslationPO::erase_message(const StringName &p_src_text, const StringName } void TranslationPO::get_message_list(List<StringName> *r_messages) const { - // PHashTranslation uses this function to get the list of msgid. + // OptimizedTranslation uses this function to get the list of msgid. // Return all the keys of translation_map under "" context. List<StringName> context_l; |