Skip to content

Commit

Permalink
list.gi: speed up NextIterator_[Dense]List
Browse files Browse the repository at this point in the history
  • Loading branch information
wilfwilson authored and fingolfin committed Jan 27, 2021
1 parent 9edd0a9 commit 11b57f5
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/list.gi
Original file line number Diff line number Diff line change
Expand Up @@ -742,25 +742,31 @@ BindGlobal( "IsDoneIterator_List",
iter -> ( iter!.pos >= iter!.len ) );

BindGlobal( "NextIterator_List", function ( iter )
if iter!.pos = Length( iter!.list ) then
local p, l;
p := iter!.pos;
if p = iter!.len then
Error("<iter> is exhausted");
fi;
iter!.pos := iter!.pos + 1;
while not IsBound( iter!.list[ iter!.pos ] ) do
iter!.pos := iter!.pos + 1;
l := iter!.list;
p := p + 1;
while not IsBound( l[ p ] ) do
p := p + 1;
od;
return iter!.list[ iter!.pos ];
iter!.pos := p;
return l[ p ];
end );

#BindGlobal( "IsDoneIterator_DenseList",
# iter -> not IsBound( iter!.list[ iter!.pos + 1 ] ) );

BindGlobal( "NextIterator_DenseList", function ( iter )
iter!.pos := iter!.pos + 1;
local p;
p := iter!.pos + 1;
iter!.pos := p;
#if not IsBound( iter!.list[ iter!.pos ] ) then
# Error("<iter> is exhausted");
#fi;
return iter!.list[ iter!.pos ];
return iter!.list[ p ];
end );

BindGlobal( "ShallowCopy_List",
Expand Down

0 comments on commit 11b57f5

Please sign in to comment.