Skip to content

Commit da1490d

Browse files
committed
1 parent 4b67e54 commit da1490d

File tree

4 files changed

+22
-39
lines changed

4 files changed

+22
-39
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5274,7 +5274,7 @@ dependencies = [
52745274
[[package]]
52755275
name = "stringdex"
52765276
version = "0.0.2"
5277-
source = "git+https://gitlab.com/yotamofek/stringdex?rev=61a1cda4f942e6a6773e4b969aff7b26903a31f8#61a1cda4f942e6a6773e4b969aff7b26903a31f8"
5277+
source = "git+https://gitlab.com/yotamofek/stringdex?rev=a1812aefdb3dce2bb85d9ec52a6e53d8eefa3c4b#a1812aefdb3dce2bb85d9ec52a6e53d8eefa3c4b"
52785278
dependencies = [
52795279
"stacker",
52805280
]

src/librustdoc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rustdoc-json-types = { path = "../rustdoc-json-types" }
2121
serde = { version = "1.0", features = ["derive"] }
2222
serde_json = "1.0"
2323
smallvec = "1.8.1"
24-
stringdex = { git = "https://gitlab.com/yotamofek/stringdex", rev = "61a1cda4f942e6a6773e4b969aff7b26903a31f8" }
24+
stringdex = { git = "https://gitlab.com/yotamofek/stringdex", rev = "a1812aefdb3dce2bb85d9ec52a6e53d8eefa3c4b" }
2525
tempfile = "3"
2626
threadpool = "1.8.1"
2727
tracing = "0.1"

src/librustdoc/html/render/search_index.rs

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,16 @@ impl SerializedSearchIndex {
9898
let root_path = doc_root.join(format!("search.index/root{resource_suffix}.js"));
9999
let column_path = doc_root.join(format!("search.index/{column_name}/"));
100100

101-
struct Consumer<'col>(&'col mut Vec<String>);
102-
103-
impl<'col> stringdex_internals::Consumer for Consumer<'col> {
104-
type Err = FromUtf8Error;
105-
106-
fn consume(&mut self, _id: u32, cell: &[u8]) -> Result<(), Self::Err> {
107-
self.0.push(String::from_utf8(cell.to_vec())?);
108-
Ok(())
109-
}
110-
}
101+
let mut consume = |_, cell: &[u8]| {
102+
column.push(String::from_utf8(cell.to_vec())?);
103+
Ok::<_, FromUtf8Error>(())
104+
};
111105

112106
stringdex_internals::read_data_from_disk_column(
113107
root_path,
114108
column_name.as_bytes(),
115109
column_path.clone(),
116-
&mut Consumer(column),
110+
&mut consume,
117111
)
118112
.map_err(|error| Error {
119113
file: column_path,
@@ -129,29 +123,20 @@ impl SerializedSearchIndex {
129123
let root_path = doc_root.join(format!("search.index/root{resource_suffix}.js"));
130124
let column_path = doc_root.join(format!("search.index/{column_name}/"));
131125

132-
struct Consumer<'col, T>(&'col mut Vec<Option<T>>);
133-
134-
impl<'col, T> stringdex_internals::Consumer for Consumer<'col, T>
135-
where
136-
T: for<'de> Deserialize<'de> + 'static,
137-
{
138-
type Err = serde_json::Error;
139-
140-
fn consume(&mut self, _id: u32, cell: &[u8]) -> Result<(), Self::Err> {
141-
if cell.is_empty() {
142-
self.0.push(None);
143-
} else {
144-
self.0.push(Some(serde_json::from_slice(cell)?));
145-
}
146-
Ok(())
126+
let mut consume = |_, cell: &[u8]| {
127+
if cell.is_empty() {
128+
column.push(None);
129+
} else {
130+
column.push(Some(serde_json::from_slice(cell)?));
147131
}
148-
}
132+
Ok::<_, serde_json::Error>(())
133+
};
149134

150135
stringdex_internals::read_data_from_disk_column(
151136
root_path,
152137
column_name.as_bytes(),
153138
column_path.clone(),
154-
&mut Consumer(column),
139+
&mut consume,
155140
)
156141
.map_err(|error| Error {
157142
file: column_path,
@@ -167,15 +152,13 @@ impl SerializedSearchIndex {
167152
let root_path = doc_root.join(format!("search.index/root{resource_suffix}.js"));
168153
let column_path = doc_root.join(format!("search.index/{column_name}/"));
169154

170-
struct Consumer<'col>(&'col mut Vec<Vec<Vec<u32>>>);
171-
172-
impl<'col> stringdex_internals::Consumer for Consumer<'col> {
173-
type Err = io::Error;
174-
175-
fn consume(&mut self, _id: u32, cell: &[u8]) -> Result<(), Self::Err> {
155+
fn consumer(
156+
column: &mut Vec<Vec<Vec<u32>>>,
157+
) -> impl FnMut(u32, &[u8]) -> io::Result<()> {
158+
|_, cell| {
176159
let mut postings = Vec::new();
177160
encode::read_postings_from_string(&mut postings, cell);
178-
self.0.push(postings);
161+
column.push(postings);
179162
Ok(())
180163
}
181164
}
@@ -184,7 +167,7 @@ impl SerializedSearchIndex {
184167
root_path,
185168
column_name.as_bytes(),
186169
column_path.clone(),
187-
&mut Consumer(column),
170+
&mut consumer(column),
188171
)
189172
.map_err(|error| Error {
190173
file: column_path,

src/tools/tidy/src/extdeps.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ALLOWED_SOURCES: &[&str] = &[
1212
// This is `rust_team_data` used by `site` in src/tools/rustc-perf,
1313
r#""git+https://github.com/rust-lang/team#a5260e76d3aa894c64c56e6ddc8545b9a98043ec""#,
1414
// TMP:
15-
r#""git+https://gitlab.com/yotamofek/stringdex?rev=61a1cda4f942e6a6773e4b969aff7b26903a31f8#61a1cda4f942e6a6773e4b969aff7b26903a31f8""#,
15+
r#""git+https://gitlab.com/yotamofek/stringdex?rev=a1812aefdb3dce2bb85d9ec52a6e53d8eefa3c4b#a1812aefdb3dce2bb85d9ec52a6e53d8eefa3c4b""#,
1616
];
1717

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

0 commit comments

Comments
 (0)