aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2024-04-20 20:28:03 +0300
committerVladimir Belyavsky <belyavskyv@gmail.com>2024-04-22 08:06:29 +0000
commit9bf6218b2d752261567fa5ab9ce2e2cb3b0312e7 (patch)
tree88b7c4e44445b3cafb757dba65832f8511f2b455
parent1c629c1a7f6f5f108989eec6cca7c0c814587232 (diff)
UrlObject: Avoid potential extra QList detaches
There might be potential extra QList detach due to the use of non-const QList iterators in UrlSearchParamsPrototype::method_delete(). To avoid this, we can use QList::removeIf() which doesn't detach if there is nothing to remove and also makes the code a bit clearer. Change-Id: Ia4d2d2d0ac2d1dc4b08ed0b34b701bab7bca6250 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/qml/jsruntime/qv4urlobject.cpp7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4urlobject.cpp b/src/qml/jsruntime/qv4urlobject.cpp
index 637d033bd4..4ece91a2a2 100644
--- a/src/qml/jsruntime/qv4urlobject.cpp
+++ b/src/qml/jsruntime/qv4urlobject.cpp
@@ -1288,12 +1288,7 @@ ReturnedValue UrlSearchParamsPrototype::method_delete(const FunctionObject *b, c
return Encode::undefined();
QList<QStringList> params = o->params();
-
- auto to_remove = std::remove_if(params.begin(), params.end(), [&name](QStringList pair) {
- return pair[0] == name;
- });
-
- params.erase(to_remove, params.end());
+ params.removeIf([&name](const auto &pair) { return pair.at(0) == name; });
o->setParams(params);