diff options
author | BlackDex <[email protected]> | 2023-03-09 16:31:28 +0100 |
---|---|---|
committer | BlackDex <[email protected]> | 2023-03-11 16:58:32 +0100 |
commit | 9e5b94924f5fea4ef405fa1f8aeb836b52f85a73 (patch) | |
tree | 83dcde146ea7557e0ef0a3209d681128a6dbc803 /src/db/models/cipher.rs | |
parent | f21089900e86274c8a89a15a6ff79dfb9c433ca2 (diff) | |
download | vaultwarden-9e5b94924f5fea4ef405fa1f8aeb836b52f85a73.tar.gz vaultwarden-9e5b94924f5fea4ef405fa1f8aeb836b52f85a73.zip |
Merge ClientIp with Headers.
Since we now use the `ClientIp` Guard on a lot more places, it also
increases the size of binary, and the macro generated code because of
this extra Guard. By merging the `ClientIp` Guard with the several
`Header` guards we have it reduces the amount of code generated
(including LLVM IR), but also a small speedup in build time.
I also spotted some small `json!()` optimizations which also reduced the
amount of code generated.
Diffstat (limited to 'src/db/models/cipher.rs')
-rw-r--r-- | src/db/models/cipher.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs index 79212f6a..9e324b7b 100644 --- a/src/db/models/cipher.rs +++ b/src/db/models/cipher.rs @@ -151,7 +151,8 @@ impl Cipher { // Get the type_data or a default to an empty json object '{}'. // If not passing an empty object, mobile clients will crash. - let mut type_data_json: Value = serde_json::from_str(&self.data).unwrap_or_else(|_| json!({})); + let mut type_data_json: Value = + serde_json::from_str(&self.data).unwrap_or_else(|_| Value::Object(serde_json::Map::new())); // NOTE: This was marked as *Backwards Compatibility Code*, but as of January 2021 this is still being used by upstream // Set the first element of the Uris array as Uri, this is needed several (mobile) clients. @@ -170,10 +171,10 @@ impl Cipher { // NOTE: This was marked as *Backwards Compatibility Code*, but as of January 2021 this is still being used by upstream // data_json should always contain the following keys with every atype - data_json["Fields"] = json!(fields_json); + data_json["Fields"] = fields_json.clone(); data_json["Name"] = json!(self.name); data_json["Notes"] = json!(self.notes); - data_json["PasswordHistory"] = json!(password_history_json); + data_json["PasswordHistory"] = password_history_json.clone(); let collection_ids = if let Some(cipher_sync_data) = cipher_sync_data { if let Some(cipher_collections) = cipher_sync_data.cipher_collections.get(&self.uuid) { |