[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Slowness in function 'open'
From: |
Daniel J Sebald |
Subject: |
Re: Slowness in function 'open' |
Date: |
Sat, 23 Jun 2007 14:48:53 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020 |
Jordi Gutierrez Hermoso wrote:
Optimized functions are good, if they fit the bill.
> The only std::list-specific functionality my code uses is that it
> avoids the resizing problem that you solved with a double-pass. In a
> way, it does this by hogging up space. Maybe there's a better
> tradeoff.
You could make a rough guess based upon reading a line of data
I'm really warming up to this guess idea.
Yeah, it isn't such a bad idea. If someone has a large datafile in ASCII, it's
likely that it is fairly well organized, i.e., doesn't have comments and each
number has the same precision. If the guess is accurate, good. If it is off
once, that reassigning of memory won't hurt too much. If it is off twice or
more, the reassigning of memory might hurt; as usual it is a tradeoff where one
tries to pick the best outcome.
I try to always avoid macros, for instance. To
paraphrase Stroustrup, macros are a deficiency in the code, the coder,
or the coding language. ;-)
That's true for high level languages
Like C++? ;-)
where one has no concern for the expense of setting up a stack and
calling a function.
The stack overhead can be avoided by inlining the function. I think
this is a C++ extension to C.
You say to-may-to, I say to-mah-to; you say inline, I say macro; to-may-to,
to-mah-to, inline, macro...
Dan