Performance optimization for minElement and maxElement

H. S. Teoh hsteoh at qfbox.info
Mon Sep 12 14:18:13 UTC 2022


On Mon, Sep 12, 2022 at 04:46:23AM -0700, Ali Çehreli via Digitalmars-d wrote:
> On 9/12/22 04:07, H. S. Teoh wrote:
> > On Sun, Sep 11, 2022 at 07:40:35PM -0700, Ali Çehreli via Digitalmars-d
> wrote:
> >> Since the minimum and maximum values of fundamental types are
> >> known, can minElement and maxElement shortcut and return that value
> >> immediately?
> >
> > No, because that value may not appear in the given range.
[...]
> I am not that silly. :) What I meant is "as soon as they see e.g. 0".
> Say, at the third element of a million-element range...
[...]

Sounds like a good idea.


T

-- 
PNP = Plug 'N' Pray


More information about the Digitalmars-d mailing list