Skip to content

Commit 2f4e31c

Browse files
committed
avm1: Avoid allocation of some static strings
Prefer creating a static `AvmString` over allocating an owned one.
1 parent 9c1a05a commit 2f4e31c

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

core/src/avm1/globals/bevel_filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,13 @@ pub fn set_blur_y<'gc>(
373373
}
374374

375375
pub fn get_type<'gc>(
376-
activation: &mut Activation<'_, 'gc, '_>,
376+
_activation: &mut Activation<'_, 'gc, '_>,
377377
this: Object<'gc>,
378378
_args: &[Value<'gc>],
379379
) -> Result<Value<'gc>, Error<'gc>> {
380380
if let Some(filter) = this.as_bevel_filter_object() {
381381
let type_: &WStr = filter.get_type().into();
382-
return Ok(AvmString::new(activation.context.gc_context, type_).into());
382+
return Ok(AvmString::from(type_).into());
383383
}
384384

385385
Ok(Value::Undefined)

core/src/avm1/globals/displacement_map_filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ pub fn set_map_point<'gc>(
219219
}
220220

221221
pub fn mode<'gc>(
222-
activation: &mut Activation<'_, 'gc, '_>,
222+
_activation: &mut Activation<'_, 'gc, '_>,
223223
this: Object<'gc>,
224224
_args: &[Value<'gc>],
225225
) -> Result<Value<'gc>, Error<'gc>> {
226226
if let Some(object) = this.as_displacement_map_filter_object() {
227227
let mode: &WStr = object.mode().into();
228-
return Ok(AvmString::new(activation.context.gc_context, mode).into());
228+
return Ok(AvmString::from(mode).into());
229229
}
230230

231231
Ok(Value::Undefined)

core/src/avm1/globals/gradient_bevel_filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,13 @@ pub fn set_quality<'gc>(
387387
}
388388

389389
pub fn get_type<'gc>(
390-
activation: &mut Activation<'_, 'gc, '_>,
390+
_activation: &mut Activation<'_, 'gc, '_>,
391391
this: Object<'gc>,
392392
_args: &[Value<'gc>],
393393
) -> Result<Value<'gc>, Error<'gc>> {
394394
if let Some(filter) = this.as_gradient_bevel_filter_object() {
395395
let type_: &WStr = filter.get_type().into();
396-
return Ok(AvmString::new(activation.context.gc_context, type_).into());
396+
return Ok(AvmString::from(type_).into());
397397
}
398398

399399
Ok(Value::Undefined)

core/src/avm1/globals/gradient_glow_filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,13 +387,13 @@ pub fn set_quality<'gc>(
387387
}
388388

389389
pub fn get_type<'gc>(
390-
activation: &mut Activation<'_, 'gc, '_>,
390+
_activation: &mut Activation<'_, 'gc, '_>,
391391
this: Object<'gc>,
392392
_args: &[Value<'gc>],
393393
) -> Result<Value<'gc>, Error<'gc>> {
394394
if let Some(filter) = this.as_gradient_glow_filter_object() {
395395
let type_: &WStr = filter.get_type().into();
396-
return Ok(AvmString::new(activation.context.gc_context, type_).into());
396+
return Ok(AvmString::from(type_).into());
397397
}
398398

399399
Ok(Value::Undefined)

0 commit comments

Comments
 (0)