@@ -715,19 +715,13 @@ themePicker.onblur = handleThemeButtonsBlur;
715
715
path : & Path ,
716
716
krate : & str ,
717
717
key : & str ,
718
- for_search_index : bool ,
719
- ) -> io:: Result < ( Vec < String > , Vec < String > , Vec < String > ) > {
718
+ ) -> io:: Result < ( Vec < String > , Vec < String > ) > {
720
719
let mut ret = Vec :: new ( ) ;
721
720
let mut krates = Vec :: new ( ) ;
722
- let mut variables = Vec :: new ( ) ;
723
721
724
722
if path. exists ( ) {
725
723
for line in BufReader :: new ( File :: open ( path) ?) . lines ( ) {
726
724
let line = line?;
727
- if for_search_index && line. starts_with ( "var R" ) {
728
- variables. push ( line. clone ( ) ) ;
729
- continue ;
730
- }
731
725
if !line. starts_with ( key) {
732
726
continue ;
733
727
}
@@ -741,7 +735,7 @@ themePicker.onblur = handleThemeButtonsBlur;
741
735
. unwrap_or_else ( || String :: new ( ) ) ) ;
742
736
}
743
737
}
744
- Ok ( ( ret, krates, variables ) )
738
+ Ok ( ( ret, krates) )
745
739
}
746
740
747
741
fn show_item ( item : & IndexItem , krate : & str ) -> String {
@@ -756,7 +750,7 @@ themePicker.onblur = handleThemeButtonsBlur;
756
750
757
751
let dst = cx. dst . join ( & format ! ( "aliases{}.js" , cx. shared. resource_suffix) ) ;
758
752
{
759
- let ( mut all_aliases, _, _ ) = try_err ! ( collect( & dst, & krate. name, "ALIASES" , false ) , & dst) ;
753
+ let ( mut all_aliases, _) = try_err ! ( collect( & dst, & krate. name, "ALIASES" ) , & dst) ;
760
754
let mut output = String :: with_capacity ( 100 ) ;
761
755
for ( alias, items) in & cx. cache . aliases {
762
756
if items. is_empty ( ) {
@@ -853,9 +847,7 @@ themePicker.onblur = handleThemeButtonsBlur;
853
847
}
854
848
855
849
let dst = cx. dst . join ( & format ! ( "source-files{}.js" , cx. shared. resource_suffix) ) ;
856
- let ( mut all_sources, _krates, _) = try_err ! ( collect( & dst, & krate. name, "sourcesIndex" ,
857
- false ) ,
858
- & dst) ;
850
+ let ( mut all_sources, _krates) = try_err ! ( collect( & dst, & krate. name, "sourcesIndex" ) , & dst) ;
859
851
all_sources. push ( format ! ( "sourcesIndex[\" {}\" ] = {};" ,
860
852
& krate. name,
861
853
hierarchy. to_json_string( ) ) ) ;
@@ -867,20 +859,15 @@ themePicker.onblur = handleThemeButtonsBlur;
867
859
868
860
// Update the search index
869
861
let dst = cx. dst . join ( & format ! ( "search-index{}.js" , cx. shared. resource_suffix) ) ;
870
- let ( mut all_indexes, mut krates, variables) = try_err ! ( collect( & dst,
871
- & krate. name,
872
- "searchIndex" ,
873
- true ) , & dst) ;
862
+ let ( mut all_indexes, mut krates) = try_err ! ( collect( & dst, & krate. name, "searchIndex" ) , & dst) ;
874
863
all_indexes. push ( search_index) ;
875
864
876
865
// Sort the indexes by crate so the file will be generated identically even
877
866
// with rustdoc running in parallel.
878
867
all_indexes. sort ( ) ;
879
868
{
880
- let mut v = String :: from ( "var N=null,E=\" \" ,T=\" t\" ,U=\" u\" ,searchIndex={};\n " ) ;
881
- v. push_str ( & minify_replacer (
882
- & format ! ( "{}\n {}" , variables. join( "" ) , all_indexes. join( "\n " ) ) ,
883
- options. enable_minification ) ) ;
869
+ let mut v = String :: from ( "var searchIndex={};\n " ) ;
870
+ v. push_str ( & all_indexes. join ( "\n " ) ) ;
884
871
// "addSearchOptions" has to be called first so the crate filtering can be set before the
885
872
// search might start (if it's set into the URL for example).
886
873
v. push_str ( "addSearchOptions(searchIndex);initSearch(searchIndex);" ) ;
@@ -981,9 +968,8 @@ themePicker.onblur = handleThemeButtonsBlur;
981
968
remote_item_type,
982
969
remote_path[ remote_path. len( ) - 1 ] ) ) ;
983
970
984
- let ( mut all_implementors, _, _) = try_err ! ( collect( & mydst, & krate. name, "implementors" ,
985
- false ) ,
986
- & mydst) ;
971
+ let ( mut all_implementors, _) = try_err ! ( collect( & mydst, & krate. name, "implementors" ) ,
972
+ & mydst) ;
987
973
all_implementors. push ( implementors) ;
988
974
// Sort the implementors by crate so the file will be generated
989
975
// identically even with rustdoc running in parallel.
@@ -1020,68 +1006,6 @@ fn write_minify(fs:&DocFS, dst: PathBuf, contents: &str, enable_minification: bo
1020
1006
}
1021
1007
}
1022
1008
1023
- fn minify_replacer (
1024
- contents : & str ,
1025
- enable_minification : bool ,
1026
- ) -> String {
1027
- use minifier:: js:: { simple_minify, Keyword , ReservedChar , Token , Tokens } ;
1028
-
1029
- if enable_minification {
1030
- let tokens: Tokens < ' _ > = simple_minify ( contents)
1031
- . into_iter ( )
1032
- . filter ( |( f, next) | {
1033
- // We keep backlines.
1034
- minifier:: js:: clean_token_except ( f, next, & |c : & Token < ' _ > | {
1035
- c. get_char ( ) != Some ( ReservedChar :: Backline )
1036
- } )
1037
- } )
1038
- . map ( |( f, _) | {
1039
- minifier:: js:: replace_token_with ( f, & |t : & Token < ' _ > | {
1040
- match * t {
1041
- Token :: Keyword ( Keyword :: Null ) => Some ( Token :: Other ( "N" ) ) ,
1042
- Token :: String ( s) => {
1043
- let s = & s[ 1 ..s. len ( ) -1 ] ; // The quotes are included
1044
- if s. is_empty ( ) {
1045
- Some ( Token :: Other ( "E" ) )
1046
- } else if s == "t" {
1047
- Some ( Token :: Other ( "T" ) )
1048
- } else if s == "u" {
1049
- Some ( Token :: Other ( "U" ) )
1050
- } else {
1051
- None
1052
- }
1053
- }
1054
- _ => None ,
1055
- }
1056
- } )
1057
- } )
1058
- . collect :: < Vec < _ > > ( )
1059
- . into ( ) ;
1060
- let o = tokens. apply ( |f| {
1061
- // We add a backline after the newly created variables.
1062
- minifier:: js:: aggregate_strings_into_array_with_separation_filter (
1063
- f,
1064
- "R" ,
1065
- Token :: Char ( ReservedChar :: Backline ) ,
1066
- // This closure prevents crates' names from being aggregated.
1067
- //
1068
- // The point here is to check if the string is preceded by '[' and
1069
- // "searchIndex". If so, it means this is a crate name and that it
1070
- // shouldn't be aggregated.
1071
- |tokens, pos| {
1072
- pos < 2 ||
1073
- !tokens[ pos - 1 ] . eq_char ( ReservedChar :: OpenBracket ) ||
1074
- tokens[ pos - 2 ] . get_other ( ) != Some ( "searchIndex" )
1075
- }
1076
- )
1077
- } )
1078
- . to_string ( ) ;
1079
- format ! ( "{}\n " , o)
1080
- } else {
1081
- format ! ( "{}\n " , contents)
1082
- }
1083
- }
1084
-
1085
1009
#[ derive( Debug , Eq , PartialEq , Hash ) ]
1086
1010
struct ItemEntry {
1087
1011
url : String ,
0 commit comments