Skip to content

Commit fd1d256

Browse files
committed
rustdoc-search: remove the now-redundant validateResult
This function dates back to 9a45c9d and seems to have been made obsolete when `addIntoResult` grew the ability to check the levenshtein distance matching with commit ba824ec.
1 parent c3def26 commit fd1d256

1 file changed

Lines changed: 0 additions & 57 deletions

File tree

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

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,25 +1329,6 @@ function initSearch(rawSearchIndex) {
13291329
return0;
13301330
});
13311331

1332-
letnameSplit=null;
1333-
if(parsedQuery.elems.length===1){
1334-
consthasPath=typeofparsedQuery.elems[0].path==="undefined";
1335-
nameSplit=hasPath ? null : parsedQuery.elems[0].path;
1336-
}
1337-
1338-
for(constresultofresult_list){
1339-
// this validation does not make sense when searching by types
1340-
if(result.dontValidate){
1341-
continue;
1342-
}
1343-
constname=result.item.name.toLowerCase(),
1344-
path=result.item.path.toLowerCase(),
1345-
parent=result.item.parent;
1346-
1347-
if(!isType&&!validateResult(name,path,nameSplit,parent)){
1348-
result.id=-1;
1349-
}
1350-
}
13511332
returntransformResults(result_list);
13521333
}
13531334

@@ -2284,44 +2265,6 @@ function initSearch(rawSearchIndex) {
22842265
returnret;
22852266
}
22862267

2287-
/**
2288-
* Validate performs the following boolean logic. For example:
2289-
* "File::open" will give IF A PARENT EXISTS => ("file" && "open")
2290-
* exists in (name || path || parent) OR => ("file" && "open") exists in
2291-
* (name || path )
2292-
*
2293-
* This could be written functionally, but I wanted to minimise
2294-
* functions on stack.
2295-
*
2296-
* @param {string} name - The name of the result
2297-
* @param {string} path - The path of the result
2298-
* @param {string} keys - The keys to be used (["file", "open"])
2299-
* @param {Object} parent - The parent of the result
2300-
*
2301-
* @return {boolean} - Whether the result is valid or not
2302-
*/
2303-
functionvalidateResult(name,path,keys,parent,maxEditDistance){
2304-
if(!keys||!keys.length){
2305-
returntrue;
2306-
}
2307-
for(constkeyofkeys){
2308-
// each check is for validation so we negate the conditions and invalidate
2309-
if(!(
2310-
// check for an exact name match
2311-
name.indexOf(key)>-1||
2312-
// then an exact path match
2313-
path.indexOf(key)>-1||
2314-
// next if there is a parent, check for exact parent match
2315-
(parent!==undefined&&parent.name!==undefined&&
2316-
parent.name.toLowerCase().indexOf(key)>-1)||
2317-
// lastly check to see if the name was an editDistance match
2318-
editDistance(name,key,maxEditDistance)<=maxEditDistance)){
2319-
returnfalse;
2320-
}
2321-
}
2322-
returntrue;
2323-
}
2324-
23252268
functionnextTab(direction){
23262269
constnext=(searchState.currentTab+direction+3)%searchState.focusedByTab.length;
23272270
searchState.focusedByTab[searchState.currentTab]=document.activeElement;

0 commit comments

Comments
 (0)