summary refs log tree commit diff
path: root/src/Utils.cpp
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2020-12-25 05:59:18 +0100
committerGitHub <noreply@github.com>2020-12-25 05:59:18 +0100
commitea5f6ca0f41b6dd91d4d01d3f575f7688f50d837 (patch)
tree09280bb5f26a818eab462a2b42680a757bb2bc5c /src/Utils.cpp
parentMerge pull request #323 from LorenDB/newProfile (diff)
parentlint (diff)
downloadnheko-ea5f6ca0f41b6dd91d4d01d3f575f7688f50d837.tar.xz
Merge pull request #358 from Nheko-Reborn/windows-fixes
Windows fixes
Diffstat (limited to 'src/Utils.cpp')
-rw-r--r--src/Utils.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp

index 1d8fcd9c..3bb090df 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp
@@ -244,20 +244,20 @@ utils::humanReadableFileSize(uint64_t bytes) int utils::levenshtein_distance(const std::string &s1, const std::string &s2) { - const int nlen = s1.size(); - const int hlen = s2.size(); + const auto nlen = s1.size(); + const auto hlen = s2.size(); if (hlen == 0) return -1; if (nlen == 1) - return s2.find(s1); + return (int)s2.find(s1); std::vector<int> row1(hlen + 1, 0); - for (int i = 0; i < nlen; ++i) { - std::vector<int> row2(1, i + 1); + for (size_t i = 0; i < nlen; ++i) { + std::vector<int> row2(1, (int)i + 1); - for (int j = 0; j < hlen; ++j) { + for (size_t j = 0; j < hlen; ++j) { const int cost = s1[i] != s2[j]; row2.push_back( std::min(row1[j + 1] + 1, std::min(row2[j] + 1, row1[j] + cost))); @@ -381,15 +381,16 @@ utils::escapeBlacklistedHtml(const QString &rawStr) "caption", "/caption", "pre", "/pre", "span", "/span", "img", "/img"}; QByteArray data = rawStr.toUtf8(); QByteArray buffer; - const size_t length = data.size(); + const int length = data.size(); buffer.reserve(length); bool escapingTag = false; - for (size_t pos = 0; pos != length; ++pos) { + for (int pos = 0; pos != length; ++pos) { switch (data.at(pos)) { case '<': { bool oneTagMatched = false; - size_t endPos = std::min(static_cast<size_t>(data.indexOf('>', pos)), - static_cast<size_t>(data.indexOf(' ', pos))); + const int endPos = + static_cast<int>(std::min(static_cast<size_t>(data.indexOf('>', pos)), + static_cast<size_t>(data.indexOf(' ', pos)))); auto mid = data.mid(pos + 1, endPos - pos - 1); for (const auto &tag : allowedTags) { @@ -543,7 +544,7 @@ utils::generateContrastingHexColor(const QString &input, const QString &backgrou // Create a color for the input auto hash = hashQString(input); // create a hue value based on the hash of the input. - auto userHue = static_cast<int>(qAbs(hash % 360)); + auto userHue = static_cast<int>(hash % 360); // start with moderate saturation and lightness values. auto sat = 220; auto lightness = 125;