@@ -24,8 +24,8 @@ module ts {
24
24
}
25
25
26
26
interface SymbolWriter {
27
- write ( text : string , kind : SymbolDisplayPartKind , symbol : Symbol ) : void ;
28
- displayPartKind ( symbol : Symbol ) : SymbolDisplayPartKind ;
27
+ writeKind ( text : string , kind : SymbolDisplayPartKind ) : void ;
28
+ writeSymbol ( text : string , symbol : Symbol ) : void ;
29
29
clear ( ) : void ;
30
30
}
31
31
@@ -911,6 +911,7 @@ module ts {
911
911
{ accessibility : SymbolAccessibility . NotAccessible , errorSymbolName : firstIdentifierName } ;
912
912
}
913
913
914
+ // Pool writers to avoid needing to allocate them for every symbol we write.
914
915
var displayPartWriters : DisplayPartsSymbolWriter [ ] = [ ] ;
915
916
var stringWriters : StringSymbolWriter [ ] = [ ] ;
916
917
@@ -940,9 +941,9 @@ module ts {
940
941
var displayParts : SymbolDisplayPart [ ] = [ ] ;
941
942
return {
942
943
displayParts : ( ) => displayParts ,
943
- write : ( text , kind , symbol ) => displayParts . push ( { text : text , kind : kind , symbol : symbol } ) ,
944
+ writeKind : ( text , kind ) => displayParts . push ( { text : text , kind : kind , symbol : undefined } ) ,
945
+ writeSymbol : ( text , symbol ) => displayParts . push ( { text : text , kind : displayPartKind ( symbol ) , symbol : symbol } ) ,
944
946
clear : ( ) => displayParts = [ ] ,
945
- displayPartKind : displayPartKind
946
947
} ;
947
948
}
948
949
@@ -955,9 +956,9 @@ module ts {
955
956
956
957
return {
957
958
string : ( ) => str ,
958
- write : text => str += text ,
959
+ writeKind : ( text , kind ) => str += text ,
960
+ writeSymbol : ( text , symbol ) => str += text ,
959
961
clear : ( ) => str = "" ,
960
- displayPartKind : ( symbol : Symbol ) : SymbolDisplayPartKind => undefined
961
962
} ;
962
963
}
963
964
@@ -1001,12 +1002,12 @@ module ts {
1001
1002
if ( symbol . declarations && symbol . declarations . length > 0 ) {
1002
1003
var declaration = symbol . declarations [ 0 ] ;
1003
1004
if ( declaration . name ) {
1004
- writer . write ( identifierToString ( declaration . name ) , writer . displayPartKind ( symbol ) , symbol ) ;
1005
+ writer . writeSymbol ( identifierToString ( declaration . name ) , symbol ) ;
1005
1006
return ;
1006
1007
}
1007
1008
}
1008
1009
1009
- writer . write ( symbol . name , writer . displayPartKind ( symbol ) , symbol ) ;
1010
+ writer . writeSymbol ( symbol . name , symbol ) ;
1010
1011
}
1011
1012
1012
1013
var needsDot = false ;
@@ -1026,7 +1027,7 @@ module ts {
1026
1027
if ( accessibleSymbolChain ) {
1027
1028
for ( var i = 0 , n = accessibleSymbolChain . length ; i < n ; i ++ ) {
1028
1029
if ( needsDot ) {
1029
- writer . write ( "." , SymbolDisplayPartKind . Punctuation , /*symbol:*/ undefined ) ;
1030
+ writer . writeKind ( "." , SymbolDisplayPartKind . Punctuation ) ;
1030
1031
}
1031
1032
1032
1033
writeSymbolName ( accessibleSymbolChain [ i ] ) ;
@@ -1040,7 +1041,7 @@ module ts {
1040
1041
}
1041
1042
1042
1043
if ( needsDot ) {
1043
- writer . write ( "." , SymbolDisplayPartKind . Punctuation , /*symbol:*/ undefined ) ;
1044
+ writer . writeKind ( "." , SymbolDisplayPartKind . Punctuation ) ;
1044
1045
}
1045
1046
1046
1047
writeSymbolName ( symbol ) ;
0 commit comments