diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2020-12-23 11:35:20 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-11 19:45:05 +0100 |
commit | f99d1d3bd7d6f752c490c358217c360b7e0bda80 (patch) | |
tree | f06dfaaec5128b6a3844b29f316e0ee20235caf0 /Libraries/LibTLS | |
parent | 4333a9a8d6d9b98e0923e09e06deb41ee5bcd5b7 (diff) | |
download | serenity-f99d1d3bd7d6f752c490c358217c360b7e0bda80.zip |
Vector: Implement `find`, `find_if`, `find_first_matching` in terms of `AK::find*`
Problem:
- The implementation of `find` is coupled to the implementation of `Vector`.
- `Vector::find` takes the predicate by value which might be expensive.
Solution:
- Decouple the implementation of `find` from `Vector` by using a
generic `find` algorithm.
- Change the name of `find` with a predicate to `find_if` so that a
binding reference can be used and the predicate can be forwarded to
avoid copies.
- Change all the `find(pred)` call sites to use `find_if`.
Diffstat (limited to 'Libraries/LibTLS')
-rw-r--r-- | Libraries/LibTLS/ClientHandshake.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Libraries/LibTLS/ClientHandshake.cpp b/Libraries/LibTLS/ClientHandshake.cpp index 1632bf6a76..b1fbaa2391 100644 --- a/Libraries/LibTLS/ClientHandshake.cpp +++ b/Libraries/LibTLS/ClientHandshake.cpp @@ -398,7 +398,7 @@ ssize_t TLSv12::handle_payload(ReadonlyBytes vbuffer) } payload_res = handle_certificate(buffer.slice(1, payload_size)); if (m_context.certificates.size()) { - auto it = m_context.certificates.find([&](auto& cert) { return cert.is_valid(); }); + auto it = m_context.certificates.find_if([](const auto& cert) { return cert.is_valid(); }); if (it.is_end()) { // no valid certificates |