Slight optimization to persistence

This commit is contained in:
Sam 2022-05-09 21:57:33 -04:00
parent 85c2a85817
commit 54a6c31c63
2 changed files with 9 additions and 8 deletions

View File

@ -1098,6 +1098,13 @@ impl Item {
pub fn item_hash(&self) -> u64 { self.hash }
pub fn persistence_item_id(&self) -> &str {
match &self.item_base {
ItemBase::Simple(item_def) => &item_def.item_definition_id,
ItemBase::Modular(mod_base) => mod_base.pseudo_item_id(),
}
}
#[cfg(test)]
pub fn create_test_item_from_kind(kind: ItemKind) -> Self {
let ability_map = &AbilityMap::load().read();

View File

@ -11,7 +11,7 @@ use common::{
character::CharacterId,
comp::{
inventory::{
item::{tool::AbilityMap, Item as VelorenItem, ItemDefinitionId, MaterialStatManifest},
item::{tool::AbilityMap, Item as VelorenItem, MaterialStatManifest},
loadout::{Loadout, LoadoutError},
loadout_builder::LoadoutBuilder,
slot::InvSlotId,
@ -165,15 +165,9 @@ pub fn convert_items_to_database_items(
bfs_queue.push_back((format!("component_{}", i), Some(component), item_id));
}
let persistence_item_id = match item.item_definition_id() {
ItemDefinitionId::Simple(id) => id.to_owned(),
ItemDefinitionId::Compound { simple_base, .. } => simple_base.to_owned(),
ItemDefinitionId::Modular { pseudo_base, .. } => pseudo_base.to_owned(),
};
let upsert = ItemModelPair {
model: Item {
item_definition_id: persistence_item_id,
item_definition_id: String::from(item.persistence_item_id()),
position,
parent_container_item_id,
item_id,