Skip to content

Commit 76f1e93

Browse files
Allow to have undefined or null as argumento to RoaringBitmap
1 parent a195cf6 commit 76f1e93

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,14 @@ class VlqHexDecoder {
10891089
class RoaringBitmap {
10901090
/** @param {string} str */
10911091
constructor(str) {
1092+
this.keys = [];
1093+
this.cardinalities = [];
1094+
this.containers = [];
1095+
1096+
if (str === undefined || str === null) {
1097+
return;
1098+
}
1099+
10921100
// https://github.com/RoaringBitmap/RoaringFormatSpec
10931101
//
10941102
// Roaring bitmaps are used for flags that can be kept in their
@@ -1113,15 +1121,12 @@ class RoaringBitmap {
11131121
} else {
11141122
is_run = new Uint8Array();
11151123
}
1116-
this.keys = [];
1117-
this.cardinalities = [];
11181124
for (let j = 0; j < size; ++j) {
11191125
this.keys.push(u8array[i] | (u8array[i + 1] << 8));
11201126
i += 2;
11211127
this.cardinalities.push((u8array[i] | (u8array[i + 1] << 8)) + 1);
11221128
i += 2;
11231129
}
1124-
this.containers = [];
11251130
let offsets = null;
11261131
if (!has_runs || this.keys.length >= 4) {
11271132
offsets = [];

0 commit comments

Comments
 (0)