avm2: Short circuit the regexp replacement logic if it's a simple (no pattern) string

This commit is contained in:
Nathan Adams 2024-08-09 17:49:18 +02:00 committed by TÖRÖK Attila
parent ef42bba20c
commit 0023062c82
1 changed files with 4 additions and 0 deletions

View File

@ -159,6 +159,10 @@ impl<'gc> RegExp<'gc> {
text: &AvmString<'gc>, text: &AvmString<'gc>,
m: &regress::Match, m: &regress::Match,
) -> WString { ) -> WString {
if !replacement.contains(b'$') {
// Nothing to do if there's no $ replacement symbols
return replacement.as_wstr().to_owned();
}
let mut ret = WString::new(); let mut ret = WString::new();
let s = replacement.as_wstr(); let s = replacement.as_wstr();
let mut chars = s.chars().peekable(); let mut chars = s.chars().peekable();