Skip to content

Commit d40c7dc

Browse files
committed
chore(iaccessible): replace optional wstring with wstring_view
1 parent c0c3317 commit d40c7dc

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/iaccessible.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,16 +597,18 @@ bool IsOnCloseButton(const NodePtr& node, POINT pt) {
597597
bool found = false;
598598
auto find_hit_button = [&](this auto&& self, const NodePtr& child) -> bool {
599599
if (GetAccessibleRole(child) == ROLE_SYSTEM_PUSHBUTTON) {
600-
std::optional<std::wstring> acc_name;
601-
GetAccessibleName(child, [&acc_name](BSTR bstr) {
600+
bool is_close_name = false;
601+
GetAccessibleName(child, [&is_close_name](BSTR bstr) {
602602
if (bstr) {
603-
acc_name = std::wstring(bstr);
603+
std::wstring_view name_view(bstr);
604+
is_close_name =
605+
(name_view.find(L"Close") != std::wstring_view::npos) ||
606+
(name_view.find(L"关闭") != std::wstring_view::npos);
604607
}
605608
});
606609
GetAccessibleSize(child, [&](RECT rect) {
607610
if (PtInRect(&rect, pt)) {
608-
if (!acc_name || acc_name->find(L"Close") != std::wstring::npos ||
609-
acc_name->find(L"关闭") != std::wstring::npos) {
611+
if (is_close_name) {
610612
found = true;
611613
}
612614
}

0 commit comments

Comments
 (0)