From 064d8bc352388243bccd25cd68683f814580903d Mon Sep 17 00:00:00 2001 From: joshwd36 Date: Wed, 22 Jul 2020 03:41:03 +0100 Subject: [PATCH] Make lifetime of return of init static to remove to_string --- boa/src/builtins/array/mod.rs | 2 +- boa/src/builtins/bigint/mod.rs | 2 +- boa/src/builtins/boolean/mod.rs | 2 +- boa/src/builtins/console/mod.rs | 2 +- boa/src/builtins/error/mod.rs | 2 +- boa/src/builtins/error/range.rs | 2 +- boa/src/builtins/error/reference.rs | 2 +- boa/src/builtins/error/syntax.rs | 2 +- boa/src/builtins/error/type.rs | 2 +- boa/src/builtins/function/mod.rs | 2 +- boa/src/builtins/global_this/mod.rs | 2 +- boa/src/builtins/infinity/mod.rs | 2 +- boa/src/builtins/json/mod.rs | 2 +- boa/src/builtins/map/mod.rs | 2 +- boa/src/builtins/math/mod.rs | 2 +- boa/src/builtins/mod.rs | 1 - boa/src/builtins/nan/mod.rs | 2 +- boa/src/builtins/number/mod.rs | 2 +- boa/src/builtins/object/mod.rs | 2 +- boa/src/builtins/regexp/mod.rs | 2 +- boa/src/builtins/string/mod.rs | 2 +- boa/src/builtins/symbol/mod.rs | 2 +- boa/src/builtins/undefined/mod.rs | 2 +- 23 files changed, 22 insertions(+), 23 deletions(-) diff --git a/boa/src/builtins/array/mod.rs b/boa/src/builtins/array/mod.rs index ede7a2cebc..0e9db7cedd 100644 --- a/boa/src/builtins/array/mod.rs +++ b/boa/src/builtins/array/mod.rs @@ -1114,7 +1114,7 @@ impl Array { /// Initialise the `Array` object on the global object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/bigint/mod.rs b/boa/src/builtins/bigint/mod.rs index 6e97a1ed70..7ec9dd3730 100644 --- a/boa/src/builtins/bigint/mod.rs +++ b/boa/src/builtins/bigint/mod.rs @@ -200,7 +200,7 @@ impl BigInt { /// Initialise the `BigInt` object on the global object. #[inline] - pub fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/boolean/mod.rs b/boa/src/builtins/boolean/mod.rs index 4dc08e2d92..5a221c12da 100644 --- a/boa/src/builtins/boolean/mod.rs +++ b/boa/src/builtins/boolean/mod.rs @@ -98,7 +98,7 @@ impl Boolean { /// Initialise the `Boolean` object on the global object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/console/mod.rs b/boa/src/builtins/console/mod.rs index dbd1da6aa6..f3f877888d 100644 --- a/boa/src/builtins/console/mod.rs +++ b/boa/src/builtins/console/mod.rs @@ -489,7 +489,7 @@ impl Console { /// Initialise the `console` object on the global object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/error/mod.rs b/boa/src/builtins/error/mod.rs index b3c20cabb4..6d0dff1a43 100644 --- a/boa/src/builtins/error/mod.rs +++ b/boa/src/builtins/error/mod.rs @@ -76,7 +76,7 @@ impl Error { /// Initialise the global object with the `Error` object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/error/range.rs b/boa/src/builtins/error/range.rs index 76c30bd5ee..d3c3da00ba 100644 --- a/boa/src/builtins/error/range.rs +++ b/boa/src/builtins/error/range.rs @@ -62,7 +62,7 @@ impl RangeError { /// Initialise the global object with the `RangeError` object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/error/reference.rs b/boa/src/builtins/error/reference.rs index e23a2f079e..574dd45998 100644 --- a/boa/src/builtins/error/reference.rs +++ b/boa/src/builtins/error/reference.rs @@ -60,7 +60,7 @@ impl ReferenceError { } /// Initialise the global object with the `ReferenceError` object. - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/error/syntax.rs b/boa/src/builtins/error/syntax.rs index dbafff7386..048d16a3dd 100644 --- a/boa/src/builtins/error/syntax.rs +++ b/boa/src/builtins/error/syntax.rs @@ -64,7 +64,7 @@ impl SyntaxError { /// Initialise the global object with the `SyntaxError` object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/error/type.rs b/boa/src/builtins/error/type.rs index 5e3e0ba864..57a7deaebc 100644 --- a/boa/src/builtins/error/type.rs +++ b/boa/src/builtins/error/type.rs @@ -68,7 +68,7 @@ impl TypeError { /// Initialise the global object with the `RangeError` object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/function/mod.rs b/boa/src/builtins/function/mod.rs index c768b7102a..9131c850a7 100644 --- a/boa/src/builtins/function/mod.rs +++ b/boa/src/builtins/function/mod.rs @@ -533,7 +533,7 @@ where /// Initialise the `Function` object on the global object. #[inline] -pub fn init(interpreter: &mut Interpreter) -> (&str, Value) { +pub fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event("function", "init"); let prototype = Value::new_object(Some(global)); diff --git a/boa/src/builtins/global_this/mod.rs b/boa/src/builtins/global_this/mod.rs index dd04e6f6a6..5a60a00640 100644 --- a/boa/src/builtins/global_this/mod.rs +++ b/boa/src/builtins/global_this/mod.rs @@ -24,7 +24,7 @@ impl GlobalThis { /// Initialize the `globalThis` property on the global object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/infinity/mod.rs b/boa/src/builtins/infinity/mod.rs index 8f3535a5ff..7cb9b78fff 100644 --- a/boa/src/builtins/infinity/mod.rs +++ b/boa/src/builtins/infinity/mod.rs @@ -24,7 +24,7 @@ impl Infinity { /// Initialize the `Infinity` property on the global object. #[inline] - pub(crate) fn init(_interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(_interpreter: &mut Interpreter) -> (&'static str, Value) { let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); (Self::NAME, Value::from(f64::INFINITY)) diff --git a/boa/src/builtins/json/mod.rs b/boa/src/builtins/json/mod.rs index 6cd91806d5..107bc81820 100644 --- a/boa/src/builtins/json/mod.rs +++ b/boa/src/builtins/json/mod.rs @@ -172,7 +172,7 @@ impl Json { /// Initialise the `JSON` object on the global object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); let json = Value::new_object(Some(global)); diff --git a/boa/src/builtins/map/mod.rs b/boa/src/builtins/map/mod.rs index 2ec6a1eaf7..ed7cd747a5 100644 --- a/boa/src/builtins/map/mod.rs +++ b/boa/src/builtins/map/mod.rs @@ -284,7 +284,7 @@ impl Map { } /// Initialise the `Map` object on the global object. - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/math/mod.rs b/boa/src/builtins/math/mod.rs index dee0367b85..b1297b4a73 100644 --- a/boa/src/builtins/math/mod.rs +++ b/boa/src/builtins/math/mod.rs @@ -697,7 +697,7 @@ impl Math { /// Initialise the `Math` object on the global object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/mod.rs b/boa/src/builtins/mod.rs index 7ef9e49513..114b7ade47 100644 --- a/boa/src/builtins/mod.rs +++ b/boa/src/builtins/mod.rs @@ -75,7 +75,6 @@ pub fn init(interpreter: &mut Interpreter) { for init in &globals { let (name, value) = init(interpreter); - let name = name.to_string(); let global = &interpreter.realm.global_obj; match global { Value::Object(ref global_object) => { diff --git a/boa/src/builtins/nan/mod.rs b/boa/src/builtins/nan/mod.rs index b4cdd4665a..eeb29c039c 100644 --- a/boa/src/builtins/nan/mod.rs +++ b/boa/src/builtins/nan/mod.rs @@ -25,7 +25,7 @@ impl NaN { /// Initialize the `NaN` property on the global object. #[inline] - pub(crate) fn init(_interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(_interpreter: &mut Interpreter) -> (&'static str, Value) { let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); (Self::NAME, Value::from(f64::NAN)) diff --git a/boa/src/builtins/number/mod.rs b/boa/src/builtins/number/mod.rs index 99a510c22a..0e2478d965 100644 --- a/boa/src/builtins/number/mod.rs +++ b/boa/src/builtins/number/mod.rs @@ -727,7 +727,7 @@ impl Number { /// Initialise the `Number` object on the global object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/object/mod.rs b/boa/src/builtins/object/mod.rs index a4e60ee8ef..b7e7562100 100644 --- a/boa/src/builtins/object/mod.rs +++ b/boa/src/builtins/object/mod.rs @@ -577,7 +577,7 @@ pub fn property_is_enumerable(this: &Value, args: &[Value], ctx: &mut Interprete /// Initialise the `Object` object on the global object. #[inline] -pub fn init(interpreter: &mut Interpreter) -> (&str, Value) { +pub fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event("object", "init"); diff --git a/boa/src/builtins/regexp/mod.rs b/boa/src/builtins/regexp/mod.rs index 8e1dfedb1c..90f1ae1694 100644 --- a/boa/src/builtins/regexp/mod.rs +++ b/boa/src/builtins/regexp/mod.rs @@ -492,7 +492,7 @@ impl RegExp { /// Initialise the `RegExp` object on the global object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/string/mod.rs b/boa/src/builtins/string/mod.rs index 282e687c61..a8957f9d36 100644 --- a/boa/src/builtins/string/mod.rs +++ b/boa/src/builtins/string/mod.rs @@ -1023,7 +1023,7 @@ impl String { /// Initialise the `String` object on the global object. #[inline] - pub(crate) fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let global = &interpreter.realm.global_obj; let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); diff --git a/boa/src/builtins/symbol/mod.rs b/boa/src/builtins/symbol/mod.rs index 51d6e39dbf..9b592f5dee 100644 --- a/boa/src/builtins/symbol/mod.rs +++ b/boa/src/builtins/symbol/mod.rs @@ -100,7 +100,7 @@ impl Symbol { /// Initialise the `Symbol` object on the global object. #[inline] - pub fn init(interpreter: &mut Interpreter) -> (&str, Value) { + pub fn init(interpreter: &mut Interpreter) -> (&'static str, Value) { let symbol_async_iterator = Symbol( Some("Symbol.asyncIterator".into()), interpreter.generate_hash(), diff --git a/boa/src/builtins/undefined/mod.rs b/boa/src/builtins/undefined/mod.rs index ec1ad280cb..ae21964a3a 100644 --- a/boa/src/builtins/undefined/mod.rs +++ b/boa/src/builtins/undefined/mod.rs @@ -24,7 +24,7 @@ impl Undefined { /// Initialize the `undefined` property on the global object. #[inline] - pub(crate) fn init(_interpreter: &mut Interpreter) -> (&str, Value) { + pub(crate) fn init(_interpreter: &mut Interpreter) -> (&'static str, Value) { let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); (Self::NAME, Value::undefined())