Hacker News new | ask | show | jobs
by tomovo 2283 days ago
In the iOS implementation, a new dispatch queue is created on each 'set' or 'get' call, from which it switches to the main queue to call MMKV, wrapped in a try/catch block.

Inside the MMKV library, a NSData object is created, another class is used to write a single "int" value to it, then the data object is used as the "raw" value for the given key.

I haven't looked any futher but already this seems like a lot of work to set a number in memory. Is there any reason for this?

1 comments

I think you are right. I was focusing on basic implementation. Now I will make the performance optimizations needed. For example using a single instance of created class for all get set methods and not create them on every call. Thanks for pointing it out.

The second thing about numbers is that its just in case you needed it for something, it is there but there are other ways to set the data too.

Why use a dispatch queue at all? You don't use an Executor on Android. Example usage of MMKV doesn't seem to show putting it in queues.
Basically I forked this code from another repo and worked over it so the initial work is theirs. I will look into optimizing this as soon as possible. What do you think? Should callbacks be used instead of Promise?