mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
AK: Add an AK::find
helper to return a reference to the found value
This is often more convenient than dealing with iterators. This commit includes a couple conversions to find_value as examples.
This commit is contained in:
parent
9cab5dc0c9
commit
7f37a8f60f
Notes:
github-actions[bot]
2025-04-06 11:46:22 +00:00
Author: https://github.com/trflynn89
Commit: 7f37a8f60f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4237
5 changed files with 34 additions and 30 deletions
|
@ -901,13 +901,11 @@ static KeyCodeData key_code_data(u32 code_point)
|
|||
{ 0xE027, {}, UIEvents::KeyCode::Key_Minus, UIEvents::KeyModifier::Mod_Keypad },
|
||||
});
|
||||
|
||||
auto it = find_if(key_code_data.begin(), key_code_data.end(), [&](auto const& data) {
|
||||
auto data = find_value(key_code_data, [&](auto const& data) {
|
||||
return data.key == code_point || data.alternate_key == code_point;
|
||||
});
|
||||
|
||||
if (it == key_code_data.end())
|
||||
return { .key = code_point };
|
||||
return *it;
|
||||
return data.value_or({ .key = code_point });
|
||||
}
|
||||
|
||||
// https://w3c.github.io/webdriver/#dfn-shifted-character
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue