[MOAB-dev] Discussion on return type of MOAB routines
Tim Tautges (ANL)
tautges at mcs.anl.gov
Fri Jan 24 11:24:00 CST 2014
Yeah, but even the ErrorCode-only class version was way slower than the one returning only ErrorCode, that's what makes
me think there's C++ stuff going on behind the scenes (or optimizations the class version doesn't get) that is causing
the big jump.
Danqing, could you check that constructor/operator= stuff and if explicit/inlined versions weren't there before, put
them in an retime? Thx.
- tim
On 01/24/2014 11:12 AM, Jed Brown wrote:
> "Tim Tautges (ANL)" <tautges at mcs.anl.gov> writes:
>> As Jed suggested,
>>> if you want to preserve all this context data, we could create an
>>> ErrorCode which is a pointer to a real ErrorContext, containing a
>>> message and other relevant info. If success, always return NULL, which
>>> for most standard compilers should translate to 0 ? Else, look deeper
>>> in to the ErrorContext object and print/discard needed info.
>>
>> But how is that different than passing back an object owning a string? Most string implementations will have the
>> character part dynamically allocated too, so in practice it should be almost the same. But the timing information is
>> very different. I wonder whether that's because the ErrorCode return is POD, which gets optimized differently than when
>> a class is returned?
>
> Presumably you're paying for the std::string copy constructor (copy by
> value, involves new dynamic allocation) followed by the std::string
> destructor for the original object. Replace it with a raw pointer and
> it'll be fast. Note that you'll need a way to collect the data behind
> the pointer so it doesn't leak if the caller discards it.
>
--
================================================================
"You will keep in perfect peace him whose mind is
steadfast, because he trusts in you." Isaiah 26:3
Tim Tautges Argonne National Laboratory
(tautges at mcs.anl.gov) (telecommuting from UW-Madison)
phone (gvoice): (608) 354-1459 1500 Engineering Dr.
fax: (608) 263-4499 Madison, WI 53706
More information about the moab-dev
mailing list