>  297 for i := n - 1; i > 0; i-- {

"i > 0" is cheaper than "i < n" on some processors :)

On Thu, Apr 20, 2017 at 3:14 AM,  <zerk...@gmail.com> wrote:
> Hi
>
> At the moment it is implemented as
>
>    295        func IsSorted(data Interface) bool {
>    296                n := data.Len()
>    297                for i := n - 1; i > 0; i-- {
>    298                        if data.Less(i, i-1) {
>    299                                return false
>    300                        }
>    301                }
>    302                return true
>    303        }
>
>
> Is there any practical (technical) reason for this loop to be
> end-to-beginning, or is it just a preference of someone who implemented it?
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to