Skip to content

Commit 213c8e9

Browse files
committed
Stop redundantly base64 encoding bitmaps into bytestrings
1 parent 46e0728 commit 213c8e9

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/librustdoc/html/render/search_index.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ impl SerializedSearchIndex {
140140
column_name.as_bytes(),
141141
column_path.clone(),
142142
&mut |_id, item| {
143-
let mut decoded = Vec::new();
144-
read_base64_from_bytes(item, &mut decoded)?;
145143
column.push(
146-
RoaringBitmap::from_bytes(&decoded)
144+
RoaringBitmap::from_bytes(item)
147145
.map(|(bitmap, _)| bitmap.to_vec())
148146
.unwrap_or_default(),
149147
);
@@ -731,12 +729,7 @@ impl SerializedSearchIndex {
731729
let mut buf = Vec::new();
732730
stringdex_internals::encode::write_bitmap_to_bytes(&value, &mut buf)
733731
.unwrap();
734-
let mut serialized_result = Vec::new();
735-
stringdex_internals::encode::write_base64_to_bytes(
736-
&buf,
737-
&mut serialized_result,
738-
);
739-
serialized_result
732+
buf
740733
}
741734
}),
742735
)

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,22 +1751,20 @@ class DocSearch {
17511751
}
17521752

17531753
/**
1754-
* @param {number} id positive-numbered generic index (the AST uses negative-numbered ones)
1754+
* @param {number} id non-negative generic index
17551755
* @returns {Promise<stringdex.RoaringBitmap>}
17561756
*/
17571757
async getGenericInvertedIndex(id) {
17581758
const gii = this.database.getData("generic_inverted_index");
17591759
if (!gii) {
17601760
return RoaringBitmap.empty();
17611761
}
1762-
const encoded = this.utf8decoder.decode(
1763-
await gii.at(id),
1764-
);
1765-
if (encoded === "" || encoded === undefined || encoded === null) {
1762+
const encoded = await gii.at(id);
1763+
if (encoded === undefined || encoded === null || encoded.length === 0) {
17661764
return RoaringBitmap.empty();
17671765
}
17681766

1769-
return new RoaringBitmap(makeUint8ArrayFromBase64(encoded));
1767+
return new RoaringBitmap(encoded);
17701768
}
17711769

17721770
/**

0 commit comments

Comments
 (0)