[Vala] foreach performance
- From: "Кутейников Дмитрий" <kuteynikov gmail com>
- To: vala-list gnome org
- Subject: [Vala] foreach performance
- Date: Tue, 16 Dec 2008 17:58:39 +0300
Hello!
Why there are no operator to remove current object in foreach block?
I have to write
foreach(Components.Obj obj in m_objects)
{
if(obj.item.x == x && obj.item.y == y)
{
Events.disappear(obj);
m_objects.remove(obj); // :(
return obj;
}
instead of
foreach(Components.Obj obj in m_objects)
{
if(obj.item.x == x && obj.item.y == y)
{
Events.disappear(obj);
remove obj;
return obj;
}
m_objects.remove(obj) will start a new search from the beginning of list so it is a great performance hit.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]