1- const BATCH_UINTS = 128
1+ const COMPAT = true // should be flipped once this is widely deployed
2+ const BATCH_UINTS = COMPAT ? 65536 : 128
23const BATCH_BYTES = BATCH_UINTS * 4
34const BATCH = BATCH_BYTES * 8 // in bits
45const MAX_REMOTE_BATCHES = 4
@@ -25,6 +26,14 @@ class LocalWants {
2526 if ( this . destroyed ) return null
2627 if ( this . any === null ) this . any = [ ]
2728
29+ if ( COMPAT ) {
30+ let r = start & ( BATCH - 1 )
31+ start -= r
32+ length += r
33+ r = length & ( BATCH - 1 )
34+ if ( r ) length = length - r + BATCH
35+ }
36+
2837 for ( let i = 0 ; i < this . any . length ; i ++ ) {
2938 const w = this . any [ i ]
3039 if ( w . start === start && w . length === length ) {
@@ -38,7 +47,7 @@ class LocalWants {
3847 this . any . push ( w )
3948 handle . addWant ( w )
4049
41- return { start, length, any : true }
50+ return { start, length, any : ! COMPAT }
4251 }
4352
4453 removeAnyRange ( start , length , handle ) {
@@ -54,7 +63,7 @@ class LocalWants {
5463
5564 const head = this . any . pop ( )
5665 if ( head !== w ) this . any [ i ] = head
57- return { start, length, any : true }
66+ return { start, length, any : ! COMPAT }
5867 }
5968
6069 return null
0 commit comments