File tree Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Expand file tree Collapse file tree 1 file changed +2
-1
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ pub mod utf8;
175
175
/// The string returned may be safely used as a literal in a regular
176
176
/// expression.
177
177
pub fn escape ( text : & str ) -> String {
178
- let mut quoted = String :: with_capacity ( text . len ( ) ) ;
178
+ let mut quoted = String :: new ( ) ;
179
179
escape_into ( text, & mut quoted) ;
180
180
quoted
181
181
}
@@ -185,6 +185,7 @@ pub fn escape(text: &str) -> String {
185
185
/// This will append escape characters into the given buffer. The characters
186
186
/// that are appended are safe to use as a literal in a regular expression.
187
187
pub fn escape_into ( text : & str , buf : & mut String ) {
188
+ buf. reserve ( text. len ( ) ) ;
188
189
for c in text. chars ( ) {
189
190
if is_meta_character ( c) {
190
191
buf. push ( '\\' ) ;
You can’t perform that action at this time.
0 commit comments