From 49685c39895af67d7ffcc50fdc02150b6ee44f72 Mon Sep 17 00:00:00 2001 From: ouwou <26526779+ouwou@users.noreply.github.com> Date: Tue, 5 Apr 2022 22:01:53 -0400 Subject: fix up a bunch of clang-tidy stuff mostly changing references, which i hope doesnt break stuff with models (TreeRow, iterators) since they gave me some strange problems in the past --- src/emojis.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/emojis.cpp') diff --git a/src/emojis.cpp b/src/emojis.cpp index dd7193a..25516d3 100644 --- a/src/emojis.cpp +++ b/src/emojis.cpp @@ -1,8 +1,9 @@ #include "emojis.hpp" #include +#include EmojiResource::EmojiResource(std::string filepath) - : m_filepath(filepath) {} + : m_filepath(std::move(filepath)) {} bool EmojiResource::Load() { m_fp = std::fopen(m_filepath.c_str(), "rb"); @@ -31,7 +32,7 @@ bool EmojiResource::Load() { std::fread(&surrogates_count, 4, 1, m_fp); std::string surrogates(surrogates_count, '\0'); std::fread(surrogates.data(), surrogates_count, 1, m_fp); - m_patterns.push_back(surrogates); + m_patterns.emplace_back(surrogates); int data_size, data_offset; std::fread(&data_size, 4, 1, m_fp); @@ -52,7 +53,7 @@ bool EmojiResource::Load() { Glib::RefPtr EmojiResource::GetPixBuf(const Glib::ustring &pattern) { const auto it = m_index.find(pattern); - if (it == m_index.end()) return Glib::RefPtr(); + if (it == m_index.end()) return {}; const int pos = it->second.first; const int len = it->second.second; std::fseek(m_fp, pos, SEEK_SET); @@ -86,17 +87,17 @@ void EmojiResource::ReplaceEmojis(Glib::RefPtr buf, int size) { else break; } - searchpos = r + pattern.size(); + searchpos = static_cast(r + pattern.size()); - const auto start_it = buf->get_iter_at_offset(r); - const auto end_it = buf->get_iter_at_offset(r + pattern.size()); + const auto start_it = buf->get_iter_at_offset(static_cast(r)); + const auto end_it = buf->get_iter_at_offset(static_cast(r + pattern.size())); auto it = buf->erase(start_it, end_it); buf->insert_pixbuf(it, pixbuf); - int alen = text.size(); + int alen = static_cast(text.size()); text = get_text(); - int blen = text.size(); + int blen = static_cast(text.size()); searchpos -= (alen - blen); } } @@ -109,10 +110,6 @@ std::string EmojiResource::GetShortCodeForPattern(const Glib::ustring &pattern) return ""; } -const std::vector &EmojiResource::GetPatterns() const { - return m_patterns; -} - const std::map &EmojiResource::GetShortCodes() const { return m_shortcode_index; } -- cgit v1.2.3