Boost logo

Boost :

Subject: Re: [boost] [system][filesystem v3] Question about error_code arguments
From: Detlef Vollmann (dv_at_[hidden])
Date: 2009-10-20 19:10:15

Steven Watanabe wrote:
> Detlef Vollmann wrote:
>> Andrey Semashev wrote:
>>> I think the performance cost of checking a reference or pointer for
>>> validity and checking some property in the error_code instance will
>>> be the same. After all, in both cases it comes down to a single
>>> comparison of two integers. Even if referencing the global default
>>> instance does add overhead, I bet it is negligible.
>> No, it isn't. The null pointer will be in a register, while the
>> global object might not even be in the cache.

> Why does the global object need to be read?
> static error_code throws_;
> error_code& throws() { return(throws_); }
> void f(error_code& ec = throws()) {
> if(&ec == &throws()) {
> throw ...;
> } else {
> ....
> }
> }
> This should not actually load anything except the address of
> the global error_code.
Loading the address from the symbol table also takes time.
With a clever linker the cost might be very small, but if you look
how many functions might get such signatures, and how often these
functions are called, it's not negligible.
It might be negligible on a CISC machine, but we don't only deal
with CISC machines.


Boost list run by bdawes at, gregod at, cpdaniel at, john at