From 651cd486eb154b655c28a3a06934d4f4cba3e595 Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Thu, 13 Dec 2018 03:17:28 -0500 Subject: [PATCH] tiny refactors --- GUI/setdialog.cpp | 9 ++++----- extensions/googletranslate/googletranslate.cpp | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/GUI/setdialog.cpp b/GUI/setdialog.cpp index f16d8e1..731551c 100644 --- a/GUI/setdialog.cpp +++ b/GUI/setdialog.cpp @@ -12,11 +12,10 @@ SetDialog::SetDialog(QWidget* parent) : QFormLayout* layout = findChild("layout"); - using Bindable = std::tuple; - for (auto[spinBox, value, label] : { - Bindable{ flushDelay, TextThread::flushDelay, FLUSH_DELAY }, - Bindable{ maxBufferSize, TextThread::maxBufferSize, MAX_BUFFER_SIZE }, - Bindable{ defaultCodepage, TextThread::defaultCodepage, DEFAULT_CODEPAGE } + for (auto[spinBox, value, label] : std::initializer_list>{ + { flushDelay, TextThread::flushDelay, FLUSH_DELAY }, + { maxBufferSize, TextThread::maxBufferSize, MAX_BUFFER_SIZE }, + { defaultCodepage, TextThread::defaultCodepage, DEFAULT_CODEPAGE } }) { spinBox = new QSpinBox(this); diff --git a/extensions/googletranslate/googletranslate.cpp b/extensions/googletranslate/googletranslate.cpp index e7732c3..020e055 100644 --- a/extensions/googletranslate/googletranslate.cpp +++ b/extensions/googletranslate/googletranslate.cpp @@ -188,7 +188,7 @@ bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo) wchar_t wbuffer[10000] = {}; MultiByteToWideChar(CP_UTF8, 0, buffer, -1, wbuffer, 10000); std::wstring response(wbuffer); - for (std::wsmatch results; std::regex_search(response, results, std::wregex(L"\\[\"(.*?)\",[n\"]")); response = results.suffix().str()) + for (std::wsmatch results; std::regex_search(response, results, std::wregex(L"\\[\"(.*?)\",[n\"]")); response = results.suffix()) translation += std::wstring(results[1]) + L" "; for (auto& c : translation) if (c == L'\\') c = 0x200b; }