Auto merge of #149887 - notriddle:stringdex/20251211, r= · rust-lang/rust@628c1c5 (original) (raw)

`@@ -54,6 +54,52 @@ class RoaringBitmap {

`

54

54

`}

`

55

55

`this.consumed_len_bytes = pspecial - i;

`

56

56

`return this;

`

``

57

`+

} else if (u8array[i] > 0xe0) {

`

``

58

`+

// Special representation of tiny sets that are runs

`

``

59

`+

const lspecial = u8array[i] & 0x0f;

`

``

60

`+

this.keysAndCardinalities = new Uint8Array(lspecial * 4);

`

``

61

`+

i += 1;

`

``

62

`+

const key = u8array[i + 2] | (u8array[i + 3] << 8);

`

``

63

`+

const value = u8array[i] | (u8array[i + 1] << 8);

`

``

64

`+

const container = new RoaringBitmapRun(1, new Uint8Array(4));

`

``

65

`+

container.array[0] = value & 0xFF;

`

``

66

`+

container.array[1] = (value >> 8) & 0xFF;

`

``

67

`+

container.array[2] = lspecial - 1;

`

``

68

`+

this.containers.push(container);

`

``

69

`+

this.keysAndCardinalities[0] = key & 0xFF;

`

``

70

`+

this.keysAndCardinalities[1] = (key >> 8) & 0xFF;

`

``

71

`+

this.keysAndCardinalities[2] = lspecial - 1;

`

``

72

`+

this.consumed_len_bytes = 5;

`

``

73

`+

return this;

`

``

74

`+

} else if (u8array[i] > 0xd0) {

`

``

75

`+

// Special representation of tiny sets that are close together

`

``

76

`+

const lspecial = u8array[i] & 0x0f;

`

``

77

`+

this.keysAndCardinalities = new Uint8Array(lspecial * 4);

`

``

78

`+

let pspecial = i + 1;

`

``

79

`+

let key = u8array[pspecial + 2] | (u8array[pspecial + 3] << 8);

`

``

80

`+

let value = u8array[pspecial] | (u8array[pspecial + 1] << 8);

`

``

81

`+

let entry = (key << 16) | value;

`

``

82

`+

let container;

`

``

83

`+

container = new RoaringBitmapArray(1, new Uint8Array(4));

`

``

84

`+

container.array[0] = value & 0xFF;

`

``

85

`+

container.array[1] = (value >> 8) & 0xFF;

`

``

86

`+

this.containers.push(container);

`

``

87

`+

this.keysAndCardinalities[0] = key;

`

``

88

`+

this.keysAndCardinalities[1] = key >> 8;

`

``

89

`+

pspecial += 4;

`

``

90

`+

for (let ispecial = 1; ispecial < lspecial; ispecial += 1) {

`

``

91

`+

entry += u8array[pspecial];

`

``

92

`+

value = entry & 0xffff;

`

``

93

`+

key = entry >> 16;

`

``

94

`+

container = this.addToArrayAt(key);

`

``

95

`+

const cardinalityOld = container.cardinality;

`

``

96

`+

container.array[cardinalityOld * 2] = value & 0xFF;

`

``

97

`+

container.array[(cardinalityOld * 2) + 1] = (value >> 8) & 0xFF;

`

``

98

`+

container.cardinality = cardinalityOld + 1;

`

``

99

`+

pspecial += 1;

`

``

100

`+

}

`

``

101

`+

this.consumed_len_bytes = pspecial - i;

`

``

102

`+

return this;

`

57

103

`} else if (u8array[i] < 0x3a) {

`

58

104

`// Special representation of tiny sets with arbitrary 32-bit integers

`

59

105

`const lspecial = u8array[i];

`

`@@ -2282,7 +2328,7 @@ function loadDatabase(hooks) {

`

2282

2328

` */

`

2283

2329

`class InlineNeighborsTree {

`

2284

2330

`/**

`

2285

``

`-

`

``

2331

`+

`

2286

2332

` * @param {number} start

`

2287

2333

` */

`

2288

2334

`constructor(

`

`@@ -2313,6 +2359,7 @@ function loadDatabase(hooks) {

`

2313

2359

`leaves_count = 0;

`

2314

2360

`}

`

2315

2361

`i += 1;

`

``

2362

`+

/** @type {Uint8Array} */

`

2316

2363

`let data = EMPTY_UINT8;

`

2317

2364

`if (!is_suffixes_only && dlen !== 0) {

`

2318

2365

`data = encoded.subarray(i, i + dlen);

`

`@@ -2326,6 +2373,7 @@ function loadDatabase(hooks) {

`

2326

2373

`const branch_dlen = encoded[i] & 0x0f;

`

2327

2374

`const branch_leaves_count = ((encoded[i] >> 4) & 0x0f) + 1;

`

2328

2375

`i += 1;

`

``

2376

`+

/** @type {Uint8Array} */

`

2329

2377

`let branch_data = EMPTY_UINT8;

`

2330

2378

`if (!is_suffixes_only && branch_dlen !== 0) {

`

2331

2379

`branch_data = encoded.subarray(i, i + branch_dlen);

`

`@@ -2654,7 +2702,7 @@ function loadDatabase(hooks) {

`

2654

2702

``

2655

2703

`/**

`

2656

2704

` * @param {string} inputBase64

`

2657

``

`-

`

``

2705

`+

`

2658

2706

` */

`

2659

2707

`function makeSearchTreeFromBase64(inputBase64) {

`

2660

2708

`const input = makeUint8ArrayFromBase64(inputBase64);

`

`@@ -3305,7 +3353,7 @@ if (typeof window !== "undefined") {

`

3305

3353

`// eslint-disable-next-line max-len

`

3306

3354

`// polyfill https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/fromBase64

`

3307

3355

`/**

`

3308

``

`-

`

``

3356

`+

`

3309

3357

` */

`

3310

3358

`//@ts-expect-error

`

3311

3359

`const makeUint8ArrayFromBase64 = Uint8Array.fromBase64 ? Uint8Array.fromBase64 : (string => {

`

`@@ -3318,7 +3366,7 @@ const makeUint8ArrayFromBase64 = Uint8Array.fromBase64 ? Uint8Array.fromBase64 :

`

3318

3366

`return bytes;

`

3319

3367

`});

`

3320

3368

`/**

`

3321

``

`-

`

``

3369

`+

`

3322

3370

` */

`

3323

3371

`//@ts-expect-error

`

3324

3372

`const makeUint8ArrayFromHex = Uint8Array.fromHex ? Uint8Array.fromHex : (string => {

`