BSON_ITER_KEY_LEN(3)

πŸ’… BSON_ITER_KEY_LEN(3)

okay so bestie, welcome to libbson's little corner of the manual, this one's called BSON_ITER_KEY_LEN and it is honestly so underrated. tiny function, huge time-save, let's get into it ✨


✨ SYNOPSIS ✨

uint32_t
bson_iter_key_len (const bson_iter_t *iter);

that's it. that's the whole vibe check. 🫢


πŸŽ€ PARAMETERS πŸŽ€

  • iter β€” a bson_iter_t. yeah. that one. the iterator you're already holding, no cap.

🌸 DESCRIPTION 🌸

so what does it do? it fetches the length of the key for the current element that iter is observing. that's the whole thing. that's the assignment. πŸ’–

and here's the iconic part β€” this is a constant time computation. so it's literally faster than calling strlen() on a key you got back from bson_iter_key(). like, why would you do the slow thing when the fast thing exists?? not me judging, just saying πŸ‘€

the way that this is just free performance sitting right there. obsessed. πŸ”₯


⭐ RETURNS ⭐

an integer representing the key length. slay. that's your answer. πŸŽ€

πŸ’Œ SEE ALSO

  • bson_iter_key() β€” to retrieve the current key. like, the key itself, not just its length. different function, different job, both iconic. πŸ‘‘

πŸ‘‘ AUTHOR

MongoDB, Inc β€” periodt. πŸ’…

2009-present, MongoDB, Inc. β€” they've been at this a minute fr fr 🫢


and that's the page!! version 2.5.6, dated Oct 09, 2026, from the libbson girlies themselves β€” go forth and skip your strlen() calls, bestie πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from