do not allocate empty strings

follow review from @pwoolcoc, and do not use

    SafeString::new(&<String>::new())

since this makes an allocation which will then just be thrown away.
Instead, we pass ""
This commit is contained in:
Igor Galić 2018-09-14 18:24:27 +02:00
parent f5c299f23c
commit 65e213309b
No known key found for this signature in database
GPG Key ID: ACFEFF7F6A123A86
4 changed files with 8 additions and 8 deletions

View File

@ -143,8 +143,8 @@ impl Blog {
name: inst.clone(),
local: false,
// We don't really care about all the following for remote instances
long_description: SafeString::new(&<String>::new()),
short_description: SafeString::new(&<String>::new()),
long_description: SafeString::new(""),
short_description: SafeString::new(""),
default_license: String::new(),
open_registrations: true,
short_description_html: String::new(),

View File

@ -205,8 +205,8 @@ impl User {
public_domain: inst.clone(),
local: false,
// We don't really care about all the following for remote instances
long_description: SafeString::new(&<String>::new()),
short_description: SafeString::new(&<String>::new()),
long_description: SafeString::new(""),
short_description: SafeString::new(""),
default_license: String::new(),
open_registrations: true,
short_description_html: String::new(),

View File

@ -125,8 +125,8 @@ fn update_settings(conn: DbConn, admin: Admin, form: LenientForm<InstanceSetting
instance.update(&*conn,
form.name.clone(),
form.open_registrations,
form.short_description.clone().to_string(),
form.long_description.clone().to_string());
form.short_description.clone(),
form.long_description.clone());
Redirect::to(uri!(admin))
})
.map_err(|e| Template::render("instance/admin", json!({

View File

@ -153,8 +153,8 @@ fn quick_setup(conn: DbConn) {
public_domain: domain,
name: name,
local: true,
long_description: SafeString::new(&<String>::new()),
short_description: SafeString::new(&<String>::new()),
long_description: SafeString::new(""),
short_description: SafeString::new(""),
default_license: String::from("CC-0"),
open_registrations: true,
short_description_html: String::new(),