monotone-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Monotone-devel] using empty() instead of size()


From: Zack Weinberg
Subject: Re: [Monotone-devel] using empty() instead of size()
Date: Mon, 22 Sep 2008 14:33:08 -0700

On Mon, Sep 22, 2008 at 2:18 PM, Markus Wanner <address@hidden> wrote:
>> I'm honestly surprised .empty() and .size() == 0 don't generate
>> identical code, but hey.  Thanks!
>
> For example for doubly linked lists, it's pretty simple to tell whether they
> are empty or not, but counting the number of elements in the list requires
> traversing the list.

Sure, but C++98 requires size() to be O(1) for every container, so
there's really no excuse for a 4-15% performance difference.

zw




reply via email to

[Prev in Thread] Current Thread [Next in Thread]