Skip to content

Commit

Permalink
Replace some JsString calls with macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Oct 10, 2022
1 parent 1e5690b commit e88673c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 31 deletions.
8 changes: 4 additions & 4 deletions boa_engine/src/builtins/date/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
string::utf16,
symbol::WellKnownSymbols,
value::{JsValue, PreferredType},
Context, JsResult, JsString,
Context, JsResult, js_string,
};
use boa_profiler::Profiler;
use chrono::{prelude::*, Duration, LocalResult};
Expand Down Expand Up @@ -1642,7 +1642,7 @@ impl Date {
.to_string()
.into())
} else {
Ok(JsString::from("Invalid Date").into())
Ok(js_string!("Invalid Date").into())
}
}

Expand Down Expand Up @@ -1744,7 +1744,7 @@ impl Date {
.to_string()
.into())
} else {
Ok(JsString::from("Invalid Date").into())
Ok(js_string!("Invalid Date").into())
}
}

Expand Down Expand Up @@ -1780,7 +1780,7 @@ impl Date {
.to_string()
.into())
} else {
Ok(JsString::from("Invalid Date").into())
Ok(js_string!("Invalid Date").into())
}
}

Expand Down
4 changes: 2 additions & 2 deletions boa_engine/src/builtins/function/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
object::FunctionBuilder,
property::{Attribute, PropertyDescriptor},
string::utf16,
Context, JsString,
Context,
};

#[allow(clippy::float_cmp)]
Expand Down Expand Up @@ -223,7 +223,7 @@ fn function_prototype_apply_on_object() {
fn closure_capture_clone() {
let mut context = Context::default();

let string = JsString::from("Hello");
let string = js_string!("Hello");
let object = context.construct_object();
object
.define_property_or_throw(
Expand Down
38 changes: 19 additions & 19 deletions boa_engine/src/builtins/intl/date_time_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
internal_methods::get_prototype_from_constructor, ConstructorBuilder, JsFunction, JsObject,
ObjectData,
},
Context, JsResult, JsString, JsValue,
Context, JsResult, JsString, JsValue, js_string,
};

use boa_gc::{Finalize, Trace};
Expand Down Expand Up @@ -84,24 +84,24 @@ impl DateTimeFormat {
prototype,
ObjectData::date_time_format(Box::new(Self {
initialized_date_time_format: true,
locale: JsString::from("en-US"),
calendar: JsString::from("gregory"),
numbering_system: JsString::from("arab"),
time_zone: JsString::from("UTC"),
weekday: JsString::from("narrow"),
era: JsString::from("narrow"),
year: JsString::from("numeric"),
month: JsString::from("narrow"),
day: JsString::from("numeric"),
day_period: JsString::from("narrow"),
hour: JsString::from("numeric"),
minute: JsString::from("numeric"),
second: JsString::from("numeric"),
fractional_second_digits: JsString::from(""),
time_zone_name: JsString::from(""),
hour_cycle: JsString::from("h24"),
pattern: JsString::from("{hour}:{minute}"),
bound_format: JsString::from("undefined"),
locale: js_string!("en-US"),
calendar: js_string!("gregory"),
numbering_system: js_string!("arab"),
time_zone: js_string!("UTC"),
weekday: js_string!("narrow"),
era: js_string!("narrow"),
year: js_string!("numeric"),
month: js_string!("narrow"),
day: js_string!("numeric"),
day_period: js_string!("narrow"),
hour: js_string!("numeric"),
minute: js_string!("numeric"),
second: js_string!("numeric"),
fractional_second_digits: js_string!(""),
time_zone_name: js_string!(""),
hour_cycle: js_string!("h24"),
pattern: js_string!("{hour}:{minute}"),
bound_format: js_string!("undefined"),
})),
);

Expand Down
12 changes: 6 additions & 6 deletions boa_engine/src/property/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty
//! [section]: https://tc39.es/ecma262/#sec-property-attributes

use crate::{JsString, JsSymbol, JsValue};
use crate::{JsString, JsSymbol, JsValue, js_string};
use boa_gc::{Finalize, Trace};
use std::fmt;

Expand Down Expand Up @@ -608,7 +608,7 @@ impl From<usize> for PropertyKey {
if let Ok(index) = u32::try_from(value) {
Self::Index(index)
} else {
Self::String(JsString::from(value.to_string()))
Self::String(js_string!(value.to_string()))
}
}
}
Expand All @@ -618,7 +618,7 @@ impl From<i64> for PropertyKey {
if let Ok(index) = u32::try_from(value) {
Self::Index(index)
} else {
Self::String(JsString::from(value.to_string()))
Self::String(js_string!(value.to_string()))
}
}
}
Expand All @@ -628,7 +628,7 @@ impl From<u64> for PropertyKey {
if let Ok(index) = u32::try_from(value) {
Self::Index(index)
} else {
Self::String(JsString::from(value.to_string()))
Self::String(js_string!(value.to_string()))
}
}
}
Expand All @@ -638,7 +638,7 @@ impl From<isize> for PropertyKey {
if let Ok(index) = u32::try_from(value) {
Self::Index(index)
} else {
Self::String(JsString::from(value.to_string()))
Self::String(js_string!(value.to_string()))
}
}
}
Expand All @@ -648,7 +648,7 @@ impl From<i32> for PropertyKey {
if let Ok(index) = u32::try_from(value) {
Self::Index(index)
} else {
Self::String(JsString::from(value.to_string()))
Self::String(js_string!(value.to_string()))
}
}
}
Expand Down

0 comments on commit e88673c

Please sign in to comment.