vulpea icon indicating copy to clipboard operation
vulpea copied to clipboard

Update the readme for the metadata part ?

Open Cletip opened this issue 3 years ago • 4 comments

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 ^^

Cletip avatar Sep 25 '22 11:09 Cletip

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

d12frosted avatar Sep 25 '22 16:09 d12frosted

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.

Cletip avatar Sep 25 '22 19:09 Cletip

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.

d12frosted avatar Sep 26 '22 05:09 d12frosted

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 ;)

Cletip avatar Sep 26 '22 17:09 Cletip