Closed varphone closed 8 months ago
rust_i18n::locale() -> String => rust_i18n::locale() -> Arc<str>
Arc<str>
is better than Arc<String>
, what do you think?
Update this new benchmark result to README.md
t time: [58.274 ns 60.222 ns 62.390 ns]
t_with_locale time: [55.395 ns 57.106 ns 59.081 ns]
t_with_args time: [167.46 ns 170.94 ns 175.64 ns]
t_with_args (str) time: [164.85 ns 165.91 ns 167.41 ns]
t_with_args (many) time: [444.04 ns 452.17 ns 463.44 ns]
t_with_threads time: [414.26 ns 422.97 ns 433.53 ns]
rust_i18n::locale() -> String => rust_i18n::locale() -> Arc<str>
Arc<str>
is better thanArc<String>
, what do you think?
The AtomicPtr
rust_i18n::locale() -> String => rust_i18n::locale() -> Arc<str>
Arc<str>
is better thanArc<String>
, what do you think?
AtomicStr
needs to hold the string content, which must be stored using a String
.
Putting the String
into Arc
can achieve zero-copy reference, so returning Arc<String>
directly is the most efficient way.
If use Arc<str>
as the return the value will produce a memory copy.
New:
i18n!("locales", fallback = ["en", "es]);
40
Improved:
RwLock
fromlocale()
andset_locale()
.t!()
.Breaking Changes:
rust_i18n::locale() -> String
=>rust_i18n::locale() -> Arc<String>
.t!() -> String
=>t!() -> Cow<str>
.