Skip to content

Commit 21b0384

Browse files
lifthrasiiralexcrichton
authored andcommitted
---
yaml --- r: 150710 b: refs/heads/try2 c: 34ece7a h: refs/heads/master v: v3
1 parent db3397e commit 21b0384

File tree

2 files changed

+40
-44
lines changed

2 files changed

+40
-44
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: dd00bf37910058d3509a7a709de7b98ca11de091
8+
refs/heads/try2: 34ece7ad718469b4634d5eadd91d078d95bbd6c5
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustdoc/html/static/main.js

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@
137137
val = valLower,
138138
typeFilter = query.type,
139139
results = [],
140-
aa = 0,
141-
bb = 0,
142140
split = valLower.split("::");
143141

144142
//remove empty keywords
@@ -150,16 +148,16 @@
150148
}
151149

152150
// quoted values mean literal search
153-
bb = searchWords.length;
151+
var nSearchWords = searchWords.length;
154152
if ((val.charAt(0) === "\"" || val.charAt(0) === "'") &&
155153
val.charAt(val.length - 1) === val.charAt(0))
156154
{
157155
val = val.substr(1, val.length - 2);
158-
for (aa = 0; aa < bb; aa += 1) {
159-
if (searchWords[aa] === val) {
156+
for (var i = 0; i < nSearchWords; i += 1) {
157+
if (searchWords[i] === val) {
160158
// filter type: ... queries
161-
if (!typeFilter || typeFilter === searchIndex[aa].ty) {
162-
results.push([aa, -1]);
159+
if (!typeFilter || typeFilter === searchIndex[i].ty) {
160+
results.push({id: i, index: -1});
163161
}
164162
}
165163
if (results.length === max) {
@@ -170,14 +168,14 @@
170168
// gather matching search results up to a certain maximum
171169
val = val.replace(/\_/g, "");
172170
for (var i = 0; i < split.length; i++) {
173-
for (aa = 0; aa < bb; aa += 1) {
174-
if (searchWords[aa].indexOf(split[i]) > -1 ||
175-
searchWords[aa].indexOf(val) > -1 ||
176-
searchWords[aa].replace(/_/g, "").indexOf(val) > -1)
171+
for (var j = 0; j < nSearchWords; j += 1) {
172+
if (searchWords[j].indexOf(split[i]) > -1 ||
173+
searchWords[j].indexOf(val) > -1 ||
174+
searchWords[j].replace(/_/g, "").indexOf(val) > -1)
177175
{
178176
// filter type: ... queries
179-
if (!typeFilter || typeFilter === searchIndex[aa].ty) {
180-
results.push([aa, searchWords[aa].replace(/_/g, "").indexOf(val)]);
177+
if (!typeFilter || typeFilter === searchIndex[j].ty) {
178+
results.push({id: j, index: searchWords[j].replace(/_/g, "").indexOf(val)});
181179
}
182180
}
183181
if (results.length === max) {
@@ -187,13 +185,12 @@
187185
}
188186
}
189187

190-
bb = results.length;
191-
for (aa = 0; aa < bb; aa += 1) {
192-
results[aa].push(searchIndex[results[aa][0]].ty);
193-
results[aa].push(searchIndex[results[aa][0]].path);
194-
results[aa].push(searchIndex[results[aa][0]].name);
195-
results[aa].push(searchIndex[results[aa][0]].parent);
196-
results[aa].push(searchIndex[results[aa][0]].crate);
188+
var nresults = results.length;
189+
for (var i = 0; i < nresults; i += 1) {
190+
results[i].word = searchWords[results[i].id];
191+
results[i].item = searchIndex[results[i].id] || {};
192+
results[i].ty = results[i].item.ty;
193+
results[i].path = results[i].item.path;
197194
}
198195
// if there are no results then return to default and fail
199196
if (results.length === 0) {
@@ -202,70 +199,70 @@
202199

203200
// sort by exact match
204201
results.sort(function search_complete_sort0(aaa, bbb) {
205-
if (searchWords[aaa[0]] === valLower &&
206-
searchWords[bbb[0]] !== valLower) {
202+
if (aaa.word === valLower &&
203+
bbb.word !== valLower) {
207204
return 1;
208205
}
209206
});
210207
// first sorting attempt
211208
// sort by item name length
212209
results.sort(function search_complete_sort1(aaa, bbb) {
213-
if (searchWords[aaa[0]].length > searchWords[bbb[0]].length) {
210+
if (aaa.word.length > bbb.word.length) {
214211
return 1;
215212
}
216213
});
217214
// second sorting attempt
218215
// sort by item name
219216
results.sort(function search_complete_sort1(aaa, bbb) {
220-
if (searchWords[aaa[0]].length === searchWords[bbb[0]].length &&
221-
searchWords[aaa[0]] > searchWords[bbb[0]]) {
217+
if (aaa.word.length === bbb.word.length &&
218+
aaa.word > bbb.word) {
222219
return 1;
223220
}
224221
});
225222
// third sorting attempt
226223
// sort by index of keyword in item name
227-
if (results[0][1] !== -1) {
224+
if (results[0].index !== -1) {
228225
results.sort(function search_complete_sort1(aaa, bbb) {
229-
if (aaa[1] > bbb[1] && bbb[1] === 0) {
226+
if (aaa.index > bbb.index && bbb.index === 0) {
230227
return 1;
231228
}
232229
});
233230
}
234231
// fourth sorting attempt
235232
// sort by type
236233
results.sort(function search_complete_sort3(aaa, bbb) {
237-
if (searchWords[aaa[0]] === searchWords[bbb[0]] &&
238-
aaa[2] > bbb[2]) {
234+
if (aaa.word === bbb.word &&
235+
aaa.ty > bbb.ty) {
239236
return 1;
240237
}
241238
});
242239
// fifth sorting attempt
243240
// sort by path
244241
results.sort(function search_complete_sort4(aaa, bbb) {
245-
if (searchWords[aaa[0]] === searchWords[bbb[0]] &&
246-
aaa[2] === bbb[2] && aaa[3] > bbb[3]) {
242+
if (aaa.word === bbb.word &&
243+
aaa.ty === bbb.ty && aaa.path > bbb.path) {
247244
return 1;
248245
}
249246
});
250247
// sixth sorting attempt
251248
// remove duplicates, according to the data provided
252-
for (aa = results.length - 1; aa > 0; aa -= 1) {
253-
if (searchWords[results[aa][0]] === searchWords[results[aa - 1][0]] &&
254-
results[aa][2] === results[aa - 1][2] &&
255-
results[aa][3] === results[aa - 1][3])
249+
for (var i = results.length - 1; i > 0; i -= 1) {
250+
if (results[i].word === results[i - 1].word &&
251+
results[i].ty === results[i - 1].ty &&
252+
results[i].path === results[i - 1].path)
256253
{
257-
results[aa][0] = -1;
254+
results[i].id = -1;
258255
}
259256
}
260257
for (var i = 0; i < results.length; i++) {
261258
var result = results[i],
262-
name = result[4].toLowerCase(),
263-
path = result[3].toLowerCase(),
264-
parent = allPaths[result[6]][result[5]];
259+
name = result.item.name.toLowerCase(),
260+
path = result.item.path.toLowerCase(),
261+
parent = allPaths[result.item.crate][result.item.parent];
265262

266263
var valid = validateResult(name, path, split, parent);
267264
if (!valid) {
268-
result[0] = -1;
265+
result.id = -1;
269266
}
270267
}
271268
return results;
@@ -495,8 +492,8 @@
495492
resultIndex = execQuery(query, 20000, index);
496493
len = resultIndex.length;
497494
for (i = 0; i < len; i += 1) {
498-
if (resultIndex[i][0] > -1) {
499-
obj = searchIndex[resultIndex[i][0]];
495+
if (resultIndex[i].id > -1) {
496+
obj = searchIndex[resultIndex[i].id];
500497
filterdata.push([obj.name, obj.ty, obj.path, obj.desc]);
501498
results.push(obj);
502499
}
@@ -580,7 +577,6 @@
580577

581578
// Draw a convenient sidebar of known crates if we have a listing
582579
if (rootPath == '../') {
583-
console.log('here');
584580
var sidebar = $('.sidebar');
585581
var div = $('<div>').attr('class', 'block crate');
586582
div.append($('<h2>').text('Crates'));

0 commit comments

Comments
 (0)