Skip to content

Commit 628c1c5

Browse files
Auto merge of #149887 - notriddle:stringdex/20251211, r=<try>
[PERF ONLY] rustdoc stringdex update
2 parents 3391c01 + e63a5ad commit 628c1c5

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5357,8 +5357,7 @@ dependencies = [
53575357
[[package]]
53585358
name = "stringdex"
53595359
version = "0.0.3"
5360-
source = "registry+https://github.com/rust-lang/crates.io-index"
5361-
checksum = "556a6126952cb2f5150057c98a77cc6c771027dea2825bf7fa03d3d638b0a4f8"
5360+
source = "git+https://gitlab.com/notriddle/stringdex?rev=1f8709f128425508223f95eaf14d9813803704ce#1f8709f128425508223f95eaf14d9813803704ce"
53625361
dependencies = [
53635362
"stacker",
53645363
]

src/librustdoc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ rustdoc-json-types = { path = "../rustdoc-json-types" }
2222
serde = { version = "1.0", features = ["derive"] }
2323
serde_json = "1.0"
2424
smallvec = "1.8.1"
25-
stringdex = "=0.0.3"
25+
stringdex = { git = "https://gitlab.com/notriddle/stringdex", rev = "1f8709f128425508223f95eaf14d9813803704ce" }
2626
tempfile = "3"
2727
threadpool = "1.8.1"
2828
tracing = "0.1"

src/librustdoc/html/static/js/stringdex.js

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,52 @@ class RoaringBitmap {
5454
}
5555
this.consumed_len_bytes = pspecial - i;
5656
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;
57103
} else if (u8array[i] < 0x3a) {
58104
// Special representation of tiny sets with arbitrary 32-bit integers
59105
const lspecial = u8array[i];
@@ -2282,7 +2328,7 @@ function loadDatabase(hooks) {
22822328
*/
22832329
class InlineNeighborsTree {
22842330
/**
2285-
* @param {Uint8Array<ArrayBuffer>} encoded
2331+
* @param {Uint8Array} encoded
22862332
* @param {number} start
22872333
*/
22882334
constructor(
@@ -2313,6 +2359,7 @@ function loadDatabase(hooks) {
23132359
leaves_count = 0;
23142360
}
23152361
i += 1;
2362+
/** @type {Uint8Array} */
23162363
let data = EMPTY_UINT8;
23172364
if (!is_suffixes_only && dlen !== 0) {
23182365
data = encoded.subarray(i, i + dlen);
@@ -2326,6 +2373,7 @@ function loadDatabase(hooks) {
23262373
const branch_dlen = encoded[i] & 0x0f;
23272374
const branch_leaves_count = ((encoded[i] >> 4) & 0x0f) + 1;
23282375
i += 1;
2376+
/** @type {Uint8Array} */
23292377
let branch_data = EMPTY_UINT8;
23302378
if (!is_suffixes_only && branch_dlen !== 0) {
23312379
branch_data = encoded.subarray(i, i + branch_dlen);
@@ -2654,7 +2702,7 @@ function loadDatabase(hooks) {
26542702

26552703
/**
26562704
* @param {string} inputBase64
2657-
* @returns {[Uint8Array<ArrayBuffer>, SearchTree]}
2705+
* @returns {[Uint8Array, SearchTree]}
26582706
*/
26592707
function makeSearchTreeFromBase64(inputBase64) {
26602708
const input = makeUint8ArrayFromBase64(inputBase64);
@@ -3305,7 +3353,7 @@ if (typeof window !== "undefined") {
33053353
// eslint-disable-next-line max-len
33063354
// polyfill https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array/fromBase64
33073355
/**
3308-
* @type {function(string): Uint8Array<ArrayBuffer>} base64
3356+
* @type {function(string): Uint8Array} base64
33093357
*/
33103358
//@ts-expect-error
33113359
const makeUint8ArrayFromBase64 = Uint8Array.fromBase64 ? Uint8Array.fromBase64 : (string => {
@@ -3318,7 +3366,7 @@ const makeUint8ArrayFromBase64 = Uint8Array.fromBase64 ? Uint8Array.fromBase64 :
33183366
return bytes;
33193367
});
33203368
/**
3321-
* @type {function(string): Uint8Array<ArrayBuffer>} base64
3369+
* @type {function(string): Uint8Array} base64
33223370
*/
33233371
//@ts-expect-error
33243372
const makeUint8ArrayFromHex = Uint8Array.fromHex ? Uint8Array.fromHex : (string => {

src/tools/tidy/src/extdeps.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const ALLOWED_SOURCES: &[&str] = &[
1111
r#""registry+https://github.com/rust-lang/crates.io-index""#,
1212
// This is `rust_team_data` used by `site` in src/tools/rustc-perf,
1313
r#""git+https://github.com/rust-lang/team#a5260e76d3aa894c64c56e6ddc8545b9a98043ec""#,
14+
// TMP
15+
r#""git+https://gitlab.com/notriddle/stringdex?rev=1f8709f128425508223f95eaf14d9813803704ce#1f8709f128425508223f95eaf14d9813803704ce""#,
1416
];
1517

1618
/// Checks for external package sources. `root` is the path to the directory that contains the

0 commit comments

Comments
 (0)