From cba3a8949fff7636adfd1eb60c3f954554f48619 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 25 Jun 2020 18:37:33 +0200 Subject: [PATCH] even more debug output added --- tools/generate_strings.cc | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/tools/generate_strings.cc b/tools/generate_strings.cc index 2fb08694..790aaa8a 100644 --- a/tools/generate_strings.cc +++ b/tools/generate_strings.cc @@ -616,6 +616,8 @@ void DictEncoder::extractWords(std::vector &candidateList) int32_t DictEncoder::evaluateCandidate(std::string &candidate) { + // XXX it looks like this is not 100% right - debug the algorithm if dictionary compression is reintroduced + // Build the score - find how much bytes can be spared by extracting this particular candidate // Limited size of the dictionary is taken into consideration @@ -1548,31 +1550,34 @@ void DataSet::prepareOutput_packed(std::ostringstream &stream, { if (lastStr != LastStr::NONE) stream << std::endl; + // Output the label - as a comment + if (stringEntryList.type != ListType::DICTIONARY) { stream << "\t// IDX__" << stringEntryList.list[idxString].alias << std::endl; } - if (!isCompressionLvl2(stringEntryList)) + // Output the source string - as a comment + + stream << "\t// '"; + for (auto &character : stringEntryList.list[idxString].string) { - stream << "\t// '"; - for (auto &character : stringEntryList.list[idxString].string) + if (character >= 32 && character <= 132 && character != 39 && character != 34) { - if (character >= 32 && character <= 132 && character != 39 && character != 34) - { - stream << character; - } - else if (character == 13) - { - stream << ""; - } - else - { - stream << "_"; - } + stream << character; + } + else if (character == 13) + { + stream << ""; + } + else + { + stream << "_"; } - stream << "'" << std::endl; } + stream << "'" << std::endl; + + // Output the encoding stream << "\t.byte "; @@ -1630,6 +1635,8 @@ void DataSet::prepareOutput() const auto &stringEntryList = stringEntryLists[idx]; const auto &stringEncodedList = stringEncodedLists[idx]; + if (stringEncodedList.empty()) continue; + // Export labels for the current list prepareOutput_labels(stream, stringEntryList, stringEncodedList);