Skip to content

Commit 39ac33a

Browse files
committed
LinkedList: Reuse _remove in free()
Saves a little duplicate code.
1 parent 877e667 commit 39ac33a

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/StringArray.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,8 @@ class LinkedList {
170170

171171
void free(){
172172
while(_root != nullptr){
173-
auto it = _root;
174-
_root = _root->next;
175-
if (_onRemove) {
176-
_onRemove(it->value());
177-
}
178-
delete it;
173+
_remove(nullptr, _root);
179174
}
180-
_root = nullptr;
181-
_last = nullptr;
182175
}
183176
};
184177

0 commit comments

Comments
 (0)