From ef75007784ddd55df4373f843698f01d7c842142 Mon Sep 17 00:00:00 2001 From: mdb Date: Sat, 10 Aug 2002 18:45:27 +0000 Subject: [PATCH] Reverted to Ray's comparison order now that I see the light in checking for less than max first to avoid a second compare in most iterations through the loop. git-svn-id: https://samskivert.googlecode.com/svn/trunk@808 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/util/ArrayUtil.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java b/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java index 4913a3ef..81222539 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java +++ b/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java @@ -1,5 +1,5 @@ // -// $Id: ArrayUtil.java,v 1.10 2002/08/10 18:42:35 mdb Exp $ +// $Id: ArrayUtil.java,v 1.11 2002/08/10 18:45:27 mdb Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Walter Korman @@ -42,12 +42,16 @@ public class ArrayUtil for (int ii=0; ii < vcount; ii++) { int value = values[ii]; - if (value > max) { + if (value < max) { + // common case- stop checking things.. + continue; + + } else if (value > max) { // new max max = value; num = 1; - } else if (value == max) { + } else { // another sighting of max num++; }