@@ -1591,7 +1591,7 @@ impl Serializer<'_> {
15911591 fn write_calling_conv ( & mut self , calling_conv : & CallingConv ) {
15921592 match self . w . last ( ) {
15931593 Some ( b' ' ) | Some ( b'(' ) => { }
1594- _ => self . w . extend ( b" " ) ,
1594+ _ => self . w . push ( b' ' ) ,
15951595 }
15961596 if !self . flags . contains ( DemangleFlags :: NO_MS_KEYWORDS ) {
15971597 match calling_conv {
@@ -1651,7 +1651,7 @@ impl Serializer<'_> {
16511651 Type :: MemberFunctionPointer ( ref symbol, _, calling_conv, _, _, ref inner) => {
16521652 self . write_pre ( inner) ;
16531653 self . write_space ( ) ;
1654- self . w . extend ( b"(" ) ;
1654+ self . w . push ( b'(' ) ;
16551655 self . write_calling_conv ( calling_conv) ;
16561656 self . write_space ( ) ;
16571657 self . write_space ( ) ;
@@ -1672,25 +1672,24 @@ impl Serializer<'_> {
16721672 Type :: CXXVBTable ( _, sc) => sc,
16731673 Type :: CXXVFTable ( _, sc) => sc,
16741674 Type :: TemplateParameterWithIndex ( n) => {
1675- self . w
1676- . extend ( format ! ( "`template-parameter{}'" , n) . as_bytes ( ) ) ;
1675+ self . w . extend ( b"`template-parameter" ) ;
1676+ self . w . extend ( itoa:: Buffer :: new ( ) . format ( * n) . as_bytes ( ) ) ;
1677+ self . w . push ( b'\'' ) ;
16771678 return ;
16781679 }
16791680 Type :: ThreadSafeStaticGuard ( num) => {
1680- self . w . extend ( format ! ( "TSS{}" , num) . as_bytes ( ) ) ;
1681+ self . w . extend ( b"TSS" ) ;
1682+ self . w . extend ( itoa:: Buffer :: new ( ) . format ( * num) . as_bytes ( ) ) ;
16811683 return ;
16821684 }
16831685 Type :: Constant ( n) => {
1684- self . w . extend ( format ! ( "{}" , n) . as_bytes ( ) ) ;
1686+ self . w . extend ( itoa :: Buffer :: new ( ) . format ( * n) . as_bytes ( ) ) ;
16851687 return ;
16861688 }
16871689 Type :: ConstantString ( _) => {
16881690 // We have no idea what the original encoding of the string is,
16891691 // and undname doesn't even try to display anything.
1690- //match str::from_utf8(s).ok() {
1691- // Some(ref s) => self.w.extend(format!("{}", s).as_bytes()),
1692- // None => {},
1693- //}
1692+ //self.w.extend(s);
16941693 return ;
16951694 }
16961695 Type :: VarArgs => {
@@ -1709,13 +1708,13 @@ impl Serializer<'_> {
17091708 | Type :: NonMemberFunction ( calling_conv, _, _, ref inner) => {
17101709 self . write_pre ( inner) ;
17111710 self . write_space ( ) ;
1712- self . w . extend ( b"(" ) ;
1711+ self . w . push ( b'(' ) ;
17131712 self . write_calling_conv ( & calling_conv) ;
17141713 }
17151714 Type :: Array ( _, _, _) => {
17161715 self . write_pre ( inner) ;
17171716 self . write_space ( ) ;
1718- self . w . extend ( b"(" ) ;
1717+ self . w . push ( b'(' ) ;
17191718 }
17201719 _ => {
17211720 self . write_pre ( inner) ;
@@ -1729,15 +1728,15 @@ impl Serializer<'_> {
17291728 } else if self . flags . contains ( DemangleFlags :: SPACE_BEFORE_POINTER ) {
17301729 self . write_space_ptr ( ) ;
17311730 }
1732- self . w . extend ( b"*" )
1731+ self . w . push ( b'*' )
17331732 }
17341733 Type :: Ref ( _, _) => {
17351734 if !self . flags . contains ( DemangleFlags :: HUG_TYPE ) {
17361735 self . write_space ( ) ;
17371736 } else if self . flags . contains ( DemangleFlags :: SPACE_BEFORE_POINTER ) {
17381737 self . write_space_ptr ( ) ;
17391738 }
1740- self . w . extend ( b"&" )
1739+ self . w . push ( b'&' )
17411740 }
17421741 Type :: RValueRef ( _, _) => {
17431742 if !self . flags . contains ( DemangleFlags :: HUG_TYPE ) {
@@ -1947,17 +1946,17 @@ impl Serializer<'_> {
19471946 match * t {
19481947 Type :: MemberFunction ( _, _, ref params, sc, ref return_type)
19491948 | Type :: NonMemberFunction ( _, ref params, sc, ref return_type) => {
1950- self . w . extend ( b"(" ) ;
1949+ self . w . push ( b'(' ) ;
19511950 self . write_types ( & params. types ) ;
1952- self . w . extend ( b")" ) ;
1951+ self . w . push ( b')' ) ;
19531952
19541953 self . write_memfn_qualifiers ( sc) ;
19551954 self . write_post ( return_type) ;
19561955 }
19571956 Type :: MemberFunctionPointer ( _, _, _, ref params, sc, ref return_type) => {
19581957 self . w . extend ( b")(" ) ;
19591958 self . write_types ( & params. types ) ;
1960- self . w . extend ( b")" ) ;
1959+ self . w . push ( b')' ) ;
19611960
19621961 self . write_post ( return_type) ;
19631962
@@ -1975,14 +1974,16 @@ impl Serializer<'_> {
19751974 Type :: MemberFunction ( _, _, _, _, _)
19761975 | Type :: NonMemberFunction ( _, _, _, _)
19771976 | Type :: Array ( _, _, _) => {
1978- self . w . extend ( b")" ) ;
1977+ self . w . push ( b')' ) ;
19791978 }
19801979 _ => { }
19811980 }
19821981 self . write_post ( inner) ;
19831982 }
19841983 Type :: Array ( len, ref inner, _sc) => {
1985- self . w . extend ( format ! ( "[{}]" , len) . as_bytes ( ) ) ;
1984+ self . w . push ( b'[' ) ;
1985+ self . w . extend ( itoa:: Buffer :: new ( ) . format ( len) . as_bytes ( ) ) ;
1986+ self . w . push ( b']' ) ;
19861987 self . write_post ( inner) ;
19871988 }
19881989 Type :: Var ( ref inner, _kind, _sc) => {
@@ -1996,9 +1997,11 @@ impl Serializer<'_> {
19961997 }
19971998 }
19981999 Type :: VCallThunk ( offset, _) => {
1999- self . w . extend ( format ! ( "{{{}," , offset) . as_bytes ( ) ) ;
2000+ self . w . push ( b'{' ) ;
2001+ self . w . extend ( itoa:: Buffer :: new ( ) . format ( offset) . as_bytes ( ) ) ;
2002+ self . w . push ( b',' ) ;
20002003 if self . flags . contains ( DemangleFlags :: SPACE_AFTER_COMMA ) {
2001- self . w . extend ( b" " ) ;
2004+ self . w . push ( b' ' ) ;
20022005 }
20032006 self . w . extend ( b"{flat}}" ) ;
20042007 }
@@ -2014,9 +2017,9 @@ impl Serializer<'_> {
20142017 . enumerate ( )
20152018 {
20162019 if idx > 0 {
2017- self . w . extend ( b"," ) ;
2020+ self . w . push ( b',' ) ;
20182021 if self . flags . contains ( DemangleFlags :: SPACE_AFTER_COMMA ) {
2019- self . w . extend ( b" " ) ;
2022+ self . w . push ( b' ' ) ;
20202023 }
20212024 }
20222025 self . write_pre ( param) ;
@@ -2027,23 +2030,23 @@ impl Serializer<'_> {
20272030 fn write_class ( & mut self , names : & Symbol , s : & str ) {
20282031 if !self . flags . contains ( DemangleFlags :: NO_CLASS_TYPE ) {
20292032 self . w . extend ( s. as_bytes ( ) ) ;
2030- self . w . extend ( b" " ) ;
2033+ self . w . push ( b' ' ) ;
20312034 }
20322035 self . write_name ( names, None ) ;
20332036 }
20342037
20352038 fn write_space_pre ( & mut self ) {
20362039 if let Some ( & c) = self . w . last ( ) {
20372040 if char:: from ( c) . is_ascii_alphabetic ( ) || c == b'&' || c == b'>' || c == b')' {
2038- self . w . extend ( b" " ) ;
2041+ self . w . push ( b' ' ) ;
20392042 }
20402043 }
20412044 }
20422045
20432046 fn write_space_ptr ( & mut self ) {
20442047 if let Some ( & c) = self . w . last ( ) {
20452048 if char:: from ( c) . is_ascii_alphabetic ( ) || c == b'>' || c == b')' {
2046- self . w . extend ( b" " ) ;
2049+ self . w . push ( b' ' ) ;
20472050 }
20482051 }
20492052 }
@@ -2056,7 +2059,7 @@ impl Serializer<'_> {
20562059 || c == b'>'
20572060 || c == b')'
20582061 {
2059- self . w . extend ( b" " ) ;
2062+ self . w . push ( b' ' ) ;
20602063 }
20612064 }
20622065 }
@@ -2117,7 +2120,9 @@ impl Serializer<'_> {
21172120 Operator :: LocalStaticGuard ( scope) => {
21182121 self . w . extend ( b"`local static guard'" ) ;
21192122 if let Some ( scope) = scope {
2120- self . w . extend ( format ! ( "{{{}}}" , scope) . as_bytes ( ) ) ;
2123+ self . w . push ( b'{' ) ;
2124+ self . w . extend ( itoa:: Buffer :: new ( ) . format ( scope) . as_bytes ( ) ) ;
2125+ self . w . push ( b'}' ) ;
21212126 }
21222127 return ;
21232128 }
@@ -2176,7 +2181,9 @@ impl Serializer<'_> {
21762181 Operator :: LocalStaticThreadGuard ( scope) => {
21772182 self . w . extend ( b"`local static thread guard'" ) ;
21782183 if let Some ( scope) = scope {
2179- self . w . extend ( format ! ( "{{{}}}" , scope) . as_bytes ( ) ) ;
2184+ self . w . push ( b'{' ) ;
2185+ self . w . extend ( itoa:: Buffer :: new ( ) . format ( scope) . as_bytes ( ) ) ;
2186+ self . w . push ( b'}' ) ;
21802187 }
21812188 return ;
21822189 }
@@ -2189,7 +2196,7 @@ impl Serializer<'_> {
21892196 Name :: Md5 ( name) => {
21902197 self . w . extend ( b"??@" ) ;
21912198 self . w . extend ( name) ;
2192- self . w . extend ( b"@" ) ;
2199+ self . w . push ( b'@' ) ;
21932200 }
21942201 Name :: Operator ( ref op) => {
21952202 self . write_space ( ) ;
@@ -2199,20 +2206,23 @@ impl Serializer<'_> {
21992206 self . w . extend ( name) ;
22002207 }
22012208 Name :: AsInterface ( name) => {
2202- self . w . extend ( b"[" ) ;
2209+ self . w . push ( b'[' ) ;
22032210 self . w . extend ( name) ;
2204- self . w . extend ( b"]" ) ;
2211+ self . w . push ( b']' ) ;
22052212 }
22062213 Name :: Template ( ref name, ref params) => {
22072214 self . write_one_name ( name) ;
22082215 self . write_tmpl_params ( params) ;
22092216 }
2210- Name :: Discriminator ( ref val) => {
2211- self . w . extend ( format ! ( "`{}'" , val) . as_bytes ( ) ) ;
2217+ Name :: Discriminator ( val) => {
2218+ self . w . push ( b'`' ) ;
2219+ self . w . extend ( itoa:: Buffer :: new ( ) . format ( val) . as_bytes ( ) ) ;
2220+ self . w . push ( b'\'' ) ;
22122221 }
22132222 Name :: ParsedName ( ref val) => {
2214- self . w
2215- . extend ( format ! ( "`{}'" , serialize( val, self . flags) ) . as_bytes ( ) ) ;
2223+ self . w . push ( b'`' ) ;
2224+ self . serialize ( val) ;
2225+ self . w . push ( b'\'' ) ;
22162226 }
22172227 Name :: AnonymousNamespace ( _) => {
22182228 self . w . extend ( b"`anonymous namespace'" ) ;
@@ -2257,7 +2267,7 @@ impl Serializer<'_> {
22572267 Name :: Md5 ( name) => {
22582268 self . w . extend ( b"??@" ) ;
22592269 self . w . extend ( name) ;
2260- self . w . extend ( b"@" ) ;
2270+ self . w . push ( b'@' ) ;
22612271 }
22622272 Name :: Operator ( ref op) => {
22632273 match * op {
@@ -2270,7 +2280,7 @@ impl Serializer<'_> {
22702280 }
22712281 Operator :: Dtor => {
22722282 if let Some ( prev) = names. scope . names . first ( ) {
2273- self . w . extend ( b"~" ) ;
2283+ self . w . push ( b'~' ) ;
22742284 self . write_one_name ( prev) ;
22752285 } else {
22762286 self . w . extend ( b"[invalid]" ) ;
@@ -2303,19 +2313,21 @@ impl Serializer<'_> {
23032313 self . w . extend ( name) ;
23042314 }
23052315 Name :: AsInterface ( name) => {
2306- self . w . extend ( b"[" ) ;
2316+ self . w . push ( b'[' ) ;
23072317 self . w . extend ( name) ;
2308- self . w . extend ( b"]" ) ;
2318+ self . w . push ( b']' ) ;
23092319 }
23102320 Name :: Template ( ref name, ref params) => {
23112321 self . write_one_name ( name) ;
23122322 self . write_tmpl_params ( params) ;
23132323 }
2314- Name :: Discriminator ( ref val) => {
2315- self . w . extend ( format ! ( "`{}'" , val) . as_bytes ( ) ) ;
2324+ Name :: Discriminator ( val) => {
2325+ self . w . push ( b'`' ) ;
2326+ self . w . extend ( itoa:: Buffer :: new ( ) . format ( val) . as_bytes ( ) ) ;
2327+ self . w . push ( b'\'' ) ;
23162328 }
23172329 Name :: ParsedName ( ref val) => {
2318- self . w . extend ( serialize ( val, self . flags ) . as_bytes ( ) ) ;
2330+ self . serialize ( val) ;
23192331 }
23202332 Name :: AnonymousNamespace ( _) => {
23212333 // this should never happen as they are handled elsewhere
@@ -2325,14 +2337,14 @@ impl Serializer<'_> {
23252337 }
23262338
23272339 fn write_tmpl_params ( & mut self , params : & Params < ' _ > ) {
2328- self . w . extend ( b"<" ) ;
2340+ self . w . push ( b'<' ) ;
23292341 if !params. types . is_empty ( ) {
23302342 self . write_types ( & params. types ) ;
23312343 if let Some ( & b'>' ) = self . w . last ( ) {
2332- self . w . extend ( b" " ) ;
2344+ self . w . push ( b' ' ) ;
23332345 }
23342346 }
2335- self . w . extend ( b">" ) ;
2347+ self . w . push ( b'>' ) ;
23362348 }
23372349}
23382350
0 commit comments