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 resource_saver_binary; @@ -183,7 +183,7 @@ void register_core_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); diff --git a/core/string/compressed_translation.cpp b/core/string/optimized_translation.cpp similarity index 88% rename from core/string/compressed_translation.cpp rename to 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 &p_from) { +void OptimizedTranslation::generate(const Ref &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 &p_from) { Vector>> buckets; Vector> table; Vector hfunc_table; - Vector<_PHashTranslationCmp> compressed; + Vector compressed; table.resize(size); hfunc_table.resize(size); @@ -76,7 +76,7 @@ void PHashTranslation::generate(const Ref &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 &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 *p_list) const { +void OptimizedTranslation::_get_property_list(List *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 similarity index 92% rename from core/string/compressed_translation.h rename to 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 &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 *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 context_l; diff --git a/doc/classes/PHashTranslation.xml b/doc/classes/OptimizedTranslation.xml similarity index 89% rename from doc/classes/PHashTranslation.xml rename to doc/classes/OptimizedTranslation.xml index 30194e9495..a5ca93c7ff 100644 --- a/doc/classes/PHashTranslation.xml +++ b/doc/classes/OptimizedTranslation.xml @@ -1,5 +1,5 @@ - + Optimized translation. diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index 7ea39ab3ef..4a4d9d8f06 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -32,7 +32,7 @@ #include "core/io/resource_saver.h" #include "core/os/file_access.h" -#include "core/string/compressed_translation.h" +#include "core/string/optimized_translation.h" #include "core/string/translation.h" String ResourceImporterCSVTranslation::get_importer_name() const { @@ -126,7 +126,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const Ref xlt = translations[i]; if (compress) { - Ref cxl = memnew(PHashTranslation); + Ref cxl = memnew(OptimizedTranslation); cxl->generate(xlt); xlt = cxl; } diff --git a/editor/project_export.cpp b/editor/project_export.cpp index 4bcb616fbd..b7dd1013f3 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -37,7 +37,7 @@ #include "core/os/dir_access.h" #include "core/os/file_access.h" #include "core/os/os.h" -#include "core/string/compressed_translation.h" +#include "core/string/optimized_translation.h" #include "editor_data.h" #include "editor_node.h" #include "editor_scale.h"