From c5b1e6988e2c32f80f6841993d159a14c34d0a1e Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Mon, 12 Aug 2019 21:01:35 -0400 Subject: [PATCH] refactor --- GUI/host/host.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/GUI/host/host.cpp b/GUI/host/host.cpp index 5dbd917..39f3285 100644 --- a/GUI/host/host.cpp +++ b/GUI/host/host.cpp @@ -175,14 +175,11 @@ namespace Host { while (WaitForSingleObject(clipboardUpdate, INFINITE) == WAIT_OBJECT_0) { - for (int retry = 0; retry < 3; ++retry) // retry loop in case something else is using the clipboard + std::optional clipboardText; + for (int retry = 0; !clipboardText && retry < 3; ++retry) // retry loop in case something else is using the clipboard { Sleep(10); - if (auto text = Util::GetClipboardText()) - { - GetThread(clipboard).AddSentence(std::move(text.value())); - break; - } + if (clipboardText = Util::GetClipboardText()) GetThread(clipboard).AddSentence(std::move(clipboardText.value())); } } throw;