[Vala] foreach performance



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]