File tree 2 files changed +17
-12
lines changed
2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 24
24
be byte aligned, and the ` bits ` segment type is now supported in patterns.
25
25
([ Richard Viney] ( https://github.com/richard-viney ) )
26
26
27
+ - The code generated for list pattern matching on the JavaScript target is now
28
+ more efficient. Gleam code that relies heavily on list pattern matching can
29
+ now be up to twice as fast.
30
+ ([ yoshi~ ] ( https://github.com/yoshi-monster ) )
31
+
27
32
### Build tool
28
33
29
34
- The build tool now supports Git dependencies. For example:
Original file line number Diff line number Diff line change @@ -29,27 +29,27 @@ export class List {
29
29
30
30
// @internal
31
31
atLeastLength ( desired ) {
32
- for ( let _ of this ) {
33
- if ( desired <= 0 ) return true ;
34
- desired -- ;
35
- }
36
- return desired <= 0 ;
32
+ let current = this ;
33
+ while ( desired -- > 0 && current ) current = current . tail ;
34
+ return current !== undefined ;
37
35
}
38
36
39
37
// @internal
40
38
hasLength ( desired ) {
41
- for ( let _ of this ) {
42
- if ( desired <= 0 ) return false ;
43
- desired -- ;
44
- }
45
- return desired === 0 ;
39
+ let current = this ;
40
+ while ( desired -- > 0 && current ) current = current . tail ;
41
+ return desired === - 1 && current instanceof Empty ;
46
42
}
47
43
48
44
// @internal
49
45
countLength ( ) {
46
+ let current = this ;
50
47
let length = 0 ;
51
- for ( let _ of this ) length ++ ;
52
- return length ;
48
+ while ( current ) {
49
+ current = current . tail ;
50
+ length ++ ;
51
+ }
52
+ return length - 1 ;
53
53
}
54
54
}
55
55
You can’t perform that action at this time.
0 commit comments