performance and cycle burning wise, would it matter much if you use structs to fetch and / or mutate data compared to having all the fields in separate memory allocations and combining them on-request?
The dapp i’m working on required occasional changes to the “base entity (which is a struct at this moment)” but i don’t like making every field that i add optional.
I personally think it would require more calculations for retrieving data but less for mutating data?
Struct
struct Data {
name: String;
description: String;
...
}
pub static DATASETS: RefCell<StableBTreeMap<ID, Data, Memory>>;
fn get_entity(id: ID) -> Entity {
let data = DATASETS.with(....);
return data;
Seperate fields
pub static NAME: RefCell<StableBTreeMap<ID, String Memory>>;
pub static DESCRIPTION: RefCell<StableBTreeMap<ID, String Memory>>;
...
fn get_entity(id: ID) -> Entity {
let name = NAME.with(....);
let description = DESCRIPTION.with(....);
let entity = Entity {
name,
description
};
return entity;
}