'Svelte store's get method lookup performance

I have a Svelte app where most of the data logic is extracted into files that define custom stores. Often, I will need to write a function that uses the same store value repeatedly:

import { get } from 'svelte/store';
import { someStore } from './myStores';

function foo(): void {
   const arr: string[] = get(someStore);
   // ...lots of operations using arr
}

My current practice is that if I only need the value of someStore once, I'll just use get(someStore) inline, but if I need it at least twice in that function I'll assign it to a local variable like above. This is because I'm not sure whether calling get over and over again would be bad for performance.

Does anyone who understands how Svelte stores are implemented have any intuition as to whether this is really necessary? Would I suffer any performance problems if I simplified my code to just use get(...) everywhere instead of creating local constants (I'm not really concerned about reactive behavior changing the returned value mid-function)? What about if the store's value is a very large object?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source