Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move duplicates removal when generating results instead of when displaying them #92127

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/librustdoc/html/static/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,26 @@ window.initSearch = function(rawSearchIndex) {
removeEmptyStringsFromArray(split);

function transformResults(results) {
var duplicates = {};
var out = [];

for (var i = 0, len = results.length; i < len; ++i) {
if (results[i].id > -1) {
var obj = searchIndex[results[i].id];
obj.lev = results[i].lev;
var result = results[i];

if (result.id > -1) {
var obj = searchIndex[result.id];
obj.lev = result.lev;
var res = buildHrefAndPath(obj);
obj.displayPath = pathSplitter(res[0]);
obj.fullPath = obj.displayPath + obj.name;
// To be sure than it some items aren't considered as duplicate.
obj.fullPath += "|" + obj.ty;

if (duplicates[obj.fullPath]) {
continue;
}
duplicates[obj.fullPath] = true;

obj.href = res[1];
out.push(obj);
if (out.length >= MAX_RESULTS) {
Expand Down Expand Up @@ -971,19 +981,11 @@ window.initSearch = function(rawSearchIndex) {
}

var output = document.createElement("div");
var duplicates = {};
var length = 0;
if (array.length > 0) {
output.className = "search-results " + extraClass;

array.forEach(function(item) {
if (item.is_alias !== true) {
if (duplicates[item.fullPath]) {
return;
}
duplicates[item.fullPath] = true;
}

var name = item.name;
var type = itemTypes[item.ty];

Expand Down