3 ms·
I've not looked at the implementation, so I can't answer the first question, but to answer your second point/question: yes! I think getting across intent is ver
by spoiler 5y ago
I've not looked at the implementation, so I can't answer the first question, but to answer your second point/question: yes! I think getting across intent is very important for the other people reading your code.
I guess here it doesn't matter as much since it's a simple enough cases, but I'm just talking in the general sense.
With that said, I think is_empty probably has very slightly smaller overhead when it comes to figuring out the author's intent. Because, well, that was the intent. Length checking against 0 is merely a method of that intent.
Also, this "intent decoding" while reading code (no pun intended) adds up in mental cost, IMO. So, it wears down the the reader/reviewer attention more quickly.