summaryrefslogtreecommitdiff
path: root/core/compressed_translation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/compressed_translation.cpp')
-rw-r--r--core/compressed_translation.cpp16
1 files changed, 0 insertions, 16 deletions
diff --git a/core/compressed_translation.cpp b/core/compressed_translation.cpp
index 9e6ba6cde2..89e738e596 100644
--- a/core/compressed_translation.cpp
+++ b/core/compressed_translation.cpp
@@ -37,7 +37,6 @@ extern "C" {
}
struct _PHashTranslationCmp {
-
int orig_len;
CharString compressed;
int offset;
@@ -65,7 +64,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
int total_string_size = 0;
for (List<StringName>::Element *E = keys.front(); E; E = E->next()) {
-
//hash string
CharString cs = E->get().operator String().utf8();
uint32_t h = hash(0, cs.get_data());
@@ -108,7 +106,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
int bucket_table_size = 0;
for (int i = 0; i < size; i++) {
-
const Vector<Pair<int, CharString>> &b = buckets[i];
Map<uint32_t, int> &t = table.write[i];
@@ -119,10 +116,8 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
int item = 0;
while (item < b.size()) {
-
uint32_t slot = hash(d, b[item].second.get_data());
if (t.has(slot)) {
-
item = 0;
d++;
t.clear();
@@ -151,7 +146,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
int collisions = 0;
for (int i = 0; i < size; i++) {
-
const Map<uint32_t, int> &t = table[i];
if (t.size() == 0) {
htw[i] = 0xFFFFFFFF; //nothing
@@ -165,7 +159,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
btw[btindex++] = hfunc_table[i];
for (Map<uint32_t, int>::Element *E = t.front(); E; E = E->next()) {
-
btw[btindex++] = E->key();
btw[btindex++] = compressed[E->get()].offset;
btw[btindex++] = compressed[E->get()].compressed.size();
@@ -187,7 +180,6 @@ void PHashTranslation::generate(const Ref<Translation> &p_from) {
}
bool PHashTranslation::_set(const StringName &p_name, const Variant &p_value) {
-
String name = p_name.operator String();
if (name == "hash_table") {
hash_table = p_value;
@@ -204,7 +196,6 @@ bool PHashTranslation::_set(const StringName &p_name, const Variant &p_value) {
}
bool PHashTranslation::_get(const StringName &p_name, Variant &r_ret) const {
-
String name = p_name.operator String();
if (name == "hash_table")
r_ret = hash_table;
@@ -219,7 +210,6 @@ bool PHashTranslation::_get(const StringName &p_name, Variant &r_ret) const {
}
StringName PHashTranslation::get_message(const StringName &p_src_text) const {
-
int htsize = hash_table.size();
if (htsize == 0)
@@ -248,9 +238,7 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
int idx = -1;
for (int i = 0; i < bucket.size; i++) {
-
if (bucket.elem[i].key == h) {
-
idx = i;
break;
}
@@ -261,13 +249,11 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
}
if (bucket.elem[idx].comp_size == bucket.elem[idx].uncomp_size) {
-
String rstr;
rstr.parse_utf8(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].uncomp_size);
return rstr;
} else {
-
CharString uncomp;
uncomp.resize(bucket.elem[idx].uncomp_size + 1);
smaz_decompress(&sptr[bucket.elem[idx].str_offset], bucket.elem[idx].comp_size, uncomp.ptrw(), bucket.elem[idx].uncomp_size);
@@ -278,13 +264,11 @@ StringName PHashTranslation::get_message(const StringName &p_src_text) const {
}
void PHashTranslation::_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);
}