mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
Use Vector::remove() in a place I wished I had it earlier.
This commit is contained in:
parent
7777c8844b
commit
9a387d96da
Notes:
sideshowbarker
2024-07-19 18:49:22 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9a387d96da2
1 changed files with 5 additions and 6 deletions
|
@ -43,13 +43,12 @@ void Object::addChild(Object& object)
|
|||
|
||||
void Object::removeChild(Object& object)
|
||||
{
|
||||
// Oh geez, Vector needs a remove() huh...
|
||||
Vector<Object*> newList;
|
||||
for (auto* child : m_children) {
|
||||
if (child != &object)
|
||||
newList.append(child);
|
||||
for (unsigned i = 0; i < m_children.size(); ++i) {
|
||||
if (m_children[i] == &object) {
|
||||
m_children.remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_children = std::move(newList);
|
||||
}
|
||||
|
||||
void Object::onTimer(TimerEvent&)
|
||||
|
|
Loading…
Add table
Reference in a new issue