d12frosted / vulpea

A collection of functions for note taking based on `org` and `org-roam`.
GNU General Public License v3.0
236 stars 12 forks source link

Update the readme for the metadata part ? #149

Open Cletip opened 1 year ago

Cletip commented 1 year ago

I was looking for how to use metadata in a good way for performance.

I was thinking about this part "Functions of interest:

vulpea-meta - function to get metadata from NOTE-OR-ID. In most cases you should not use this function unless performance is important. In this case, take a look at bang functions, e.g. vulpea-meta-get!"

I do believe that in the end, from what I understood from the code, most of the functions boil down to "vulpea-buffer-meta-X" style functions. So I thought, according to the readme, that there was a difference between the functions. But actually, I think not ^^

d12frosted commented 1 year ago

They are different. Bang variants accept metadata as their argument.

https://github.com/d12frosted/vulpea/blob/f74575ebad8e6f7e5f7713a121bcdb939dcac83e/vulpea-meta.el#L91-L107

You see, vulpea-meta-get actually parses metadata using vulpea-meta and then passes it to vulpea-buffer-meta-get!.

Parsing metadata is not that expensive, but is not free. So if you want to read multiple values from the metadata list, you better parse metadata once using vulpea-meta and then use it to access needed values. For example, I use it in vino:

https://github.com/d12frosted/vino/blob/0ddf2268a716165c05efe1282269772e35415ab0/vino.el#L632-L670

Cletip commented 1 year ago

Oh right, I didn't quite understand. I thought the function was the same thing in the end, because one refers to the other (I had looked at how it was made). But in fact, one refers to the other WITH another, hence the difference in performance you mention. Okay, I just figured it out.

I had a little trouble understanding, because the readme have"vulpea-meta-get!" and not "vulpea-meta-get", and knowing that other function with "!" existed, I just thought that one was more efficient than the other.

Thanks you a lot for your answer.

d12frosted commented 1 year ago

You're welcome. Thanks for reading README. I think I need to revamp some sections to make them more clear and reflect some of the latest changes.

Cletip commented 1 year ago

Np. By the way, I find your readme particularly well done: there are many examples and I find it well ordered. If I can make a criticism, I find that the part about metadata is "separate", which may be confusing. Well, this is only my opinion.

Keep me informed about the moddifications of the readme if you make some change, you will have an external opinion ^^

I don't close the issue, but you can do it if you want ;)