perf(send): poll the clipboard for the paste hint only when it helps
The send tab read the OS clipboard every frame the paste button was hovered, to preview a pasted address. SDL's clipboard read is a synchronous round-trip that can stall, and the preview can only ever latch when the recipient field is empty, so most of those reads were wasted work. - The clipboard is now read only while the button is hovered and the recipient field is empty, polled once on hover entry and then at most twice a second. - Trimming the clipboard text moves to a shared helper that also bounds the copy so a pathological multi-megabyte clipboard is ignored. Tests: the trim helper handles null, surrounding whitespace, an all-whitespace string, and the length bound. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -18121,6 +18121,12 @@ void testContactsTextHelpers() {
|
||||
for (float maxW = -1; maxW < 700; maxW += 13.0f)
|
||||
EXPECT_EQ(dragonx::util::truncateMiddleToFit(s, 5, 5, maxW, meas), oldFit(s, 5, 5, maxW));
|
||||
}
|
||||
|
||||
EXPECT_EQ(dragonx::util::trimmedClipboardText(nullptr), std::string());
|
||||
EXPECT_EQ(dragonx::util::trimmedClipboardText(" zs1abc\n"), std::string("zs1abc"));
|
||||
EXPECT_EQ(dragonx::util::trimmedClipboardText("\t\r\n "), std::string());
|
||||
EXPECT_EQ(dragonx::util::trimmedClipboardText(std::string(2000, 'a').c_str()), std::string());
|
||||
EXPECT_EQ(dragonx::util::trimmedClipboardText(std::string(1024, 'a').c_str()).size(), (size_t)1024);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user