@@ -1197,110 +1197,19 @@ window.initSearch = function(rawSearchIndex) {
11971197 }
11981198
11991199 function execSearch ( query , searchWords , filterCrates ) {
1200- function getSmallest ( arrays , positions , notDuplicates ) {
1201- var start = null ;
1202-
1203- for ( var it = 0 , len = positions . length ; it < len ; ++ it ) {
1204- if ( arrays [ it ] . length > positions [ it ] &&
1205- ( start === null || start > arrays [ it ] [ positions [ it ] ] . lev ) &&
1206- ! notDuplicates [ arrays [ it ] [ positions [ it ] ] . fullPath ] ) {
1207- start = arrays [ it ] [ positions [ it ] ] . lev ;
1208- }
1209- }
1210- return start ;
1211- }
1212-
1213- function mergeArrays ( arrays ) {
1214- var ret = [ ] ;
1215- var positions = [ ] ;
1216- var notDuplicates = { } ;
1217-
1218- for ( var x = 0 , arrays_len = arrays . length ; x < arrays_len ; ++ x ) {
1219- positions . push ( 0 ) ;
1220- }
1221- while ( ret . length < MAX_RESULTS ) {
1222- var smallest = getSmallest ( arrays , positions , notDuplicates ) ;
1223-
1224- if ( smallest === null ) {
1225- break ;
1226- }
1227- for ( x = 0 ; x < arrays_len && ret . length < MAX_RESULTS ; ++ x ) {
1228- if ( arrays [ x ] . length > positions [ x ] &&
1229- arrays [ x ] [ positions [ x ] ] . lev === smallest &&
1230- ! notDuplicates [ arrays [ x ] [ positions [ x ] ] . fullPath ] ) {
1231- ret . push ( arrays [ x ] [ positions [ x ] ] ) ;
1232- notDuplicates [ arrays [ x ] [ positions [ x ] ] . fullPath ] = true ;
1233- positions [ x ] += 1 ;
1234- }
1235- }
1236- }
1237- return ret ;
1238- }
1239-
1240- // Split search query by ",", while respecting angle bracket nesting.
1241- // Since "<" is an alias for the Ord family of traits, it also uses
1242- // lookahead to distinguish "<"-as-less-than from "<"-as-angle-bracket.
1243- //
1244- // tokenizeQuery("A<B, C>, D") == ["A<B, C>", "D"]
1245- // tokenizeQuery("A<B, C, D") == ["A<B", "C", "D"]
1246- function tokenizeQuery ( raw ) {
1247- var i , matched ;
1248- var l = raw . length ;
1249- var depth = 0 ;
1250- var nextAngle = / ( < | > ) / g;
1251- var ret = [ ] ;
1252- var start = 0 ;
1253- for ( i = 0 ; i < l ; ++ i ) {
1254- switch ( raw [ i ] ) {
1255- case "<" :
1256- nextAngle . lastIndex = i + 1 ;
1257- matched = nextAngle . exec ( raw ) ;
1258- if ( matched && matched [ 1 ] === '>' ) {
1259- depth += 1 ;
1260- }
1261- break ;
1262- case ">" :
1263- if ( depth > 0 ) {
1264- depth -= 1 ;
1265- }
1266- break ;
1267- case "," :
1268- if ( depth === 0 ) {
1269- ret . push ( raw . substring ( start , i ) ) ;
1270- start = i + 1 ;
1271- }
1272- break ;
1273- }
1274- }
1275- if ( start !== i ) {
1276- ret . push ( raw . substring ( start , i ) ) ;
1277- }
1278- return ret ;
1279- }
1280-
1281- var queries = tokenizeQuery ( query . raw ) ;
1200+ query = query . raw . trim ( ) ;
12821201 var results = {
12831202 "in_args" : [ ] ,
12841203 "returned" : [ ] ,
12851204 "others" : [ ] ,
12861205 } ;
12871206
1288- for ( var i = 0 , len = queries . length ; i < len ; ++ i ) {
1289- query = queries [ i ] . trim ( ) ;
1290- if ( query . length !== 0 ) {
1291- var tmp = execQuery ( getQuery ( query ) , searchWords , filterCrates ) ;
1207+ if ( query . length !== 0 ) {
1208+ var tmp = execQuery ( getQuery ( query ) , searchWords , filterCrates ) ;
12921209
1293- results . in_args . push ( tmp . in_args ) ;
1294- results . returned . push ( tmp . returned ) ;
1295- results . others . push ( tmp . others ) ;
1296- }
1297- }
1298- if ( queries . length > 1 ) {
1299- return {
1300- "in_args" : mergeArrays ( results . in_args ) ,
1301- "returned" : mergeArrays ( results . returned ) ,
1302- "others" : mergeArrays ( results . others ) ,
1303- } ;
1210+ results . in_args . push ( tmp . in_args ) ;
1211+ results . returned . push ( tmp . returned ) ;
1212+ results . others . push ( tmp . others ) ;
13041213 }
13051214 return {
13061215 "in_args" : results . in_args [ 0 ] ,
0 commit comments