Skip to content

Commit 9aa5552

Browse files
committed
Improve isStrictPrefix (shorter and faster!)
1 parent 6b204ad commit 9aa5552

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rascal-textmate-core/src/main/rascal/util/ListUtil.rsc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module util::ListUtil
22

33
import List;
4+
import util::Benchmark;
5+
import IO;
46

57
@synopsis{
68
Representation of a traversal direction along a list
@@ -30,4 +32,4 @@ list[&T] dupLast(list[&T] l) = reverse(dup(reverse(l))); // TODO: Optimize/avoid
3032
}
3133

3234
bool isStrictPrefix(list[&T] l1, list[&T] l2)
33-
= size(l1) < size(l2) && !any(i <- [0..size(l1)], l1[i] != l2[i]);
35+
= size(l1) < size(l2) && l1 == l2[..size(l2)];

0 commit comments

Comments
 (0)