From 9bf6218b2d752261567fa5ab9ce2e2cb3b0312e7 Mon Sep 17 00:00:00 2001 From: Vladimir Belyavsky Date: Sat, 20 Apr 2024 20:28:03 +0300 Subject: 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 --- src/qml/jsruntime/qv4urlobject.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/qml/jsruntime') 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 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); -- cgit v1.2.3