Treating the abusive unsigned syndrome
Christopher Wright
dhasenan at gmail.com
Wed Nov 26 15:31:13 PST 2008
Andrei Alexandrescu wrote:
> bearophile wrote:
>> Nick Sabalausky:
>>> Oh, right. For some stupid reason I was forgetting that the param
>>> would always be an array and therefore be eligible for the existing
>>> array property syntax (and that .length always returns a uint).
>>
>> From the len() code I have posted you can see there are other places
>> where you want to use len(), in particular to count the number of
>> items that a lazy generator (opApply for now) yields.
>>
>> Bye,
>> bearophile
>
> I'm rather weary of a short and suggestive name that embodies a linear
> operation. I recall there was a discussion about that a while ago in
> this newsgroup. I'd rather call it linearLength or something that
> suggests it's a best-effort function that may take O(n).
My personal rules of optimization:
- I don't know what's slow.
- I don't know what's called often enough to be worth speeding up.
- Most of the time, my data sets are small.
If getting the length of an array were a linear operation, that wouldn't
much affect any of my code. Most of my arrays are probably no larger
than twenty elements, and I don't often need to get their lengths.
If I need to change data structures for better performance, I'd like to
be able to replace them (or switch to generators) without undo effort.
Things like changing function names according to the algorithmic
complexity of the implementation just hurts.
> Andrei
More information about the Digitalmars-d
mailing list