Subject: Re: [boost] [unordered] please don't allocate memory in the default constructor
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2009-08-24 15:44:15
Thorsten Ottosen wrote:
> Daniel James skrev:
> > The implementation also has to make sure the end iterator is valid for
> > empty containers. Currently the end iterator points to the sentinel
> > bucket so that the iterators don't need to be able to tell when
> > they've reached the end of the buckets, instead I'd have to use null
> > pointers for the end iterators and add a mechanism to detect when the
> > end of the buckets is reached - making iteration a bit slower. I'm not
> > sure if the trade off is worth it.
> Is it noticable slower?
You might also point the default constructed instance to a special, static bucket so the end iterator can refer to that. (Non-end iterators must compare equal against that special bucket, of course, once they advance far enough.) The check for empty is a check for a reference to that special bucket rather than to a null bucket pointer, or whatever. I won't begin to speculate on the performance (dis)advantage of this approach as I've not looked at any of the code.
Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP http://www.sig.com
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk