You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2012/08/17 22:46:16 UTC

svn commit: r1374431 - /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/fst/Util.java

Author: dweiss
Date: Fri Aug 17 20:46:16 2012
New Revision: 1374431

URL: http://svn.apache.org/viewvc?rev=1374431&view=rev
Log:
Rewrite the copying loop slightly; scratch.grow has an assert offset == 0
so moved this reset up before grow.

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/fst/Util.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/fst/Util.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/fst/Util.java?rev=1374431&r1=1374430&r2=1374431&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/fst/Util.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/fst/Util.java Fri Aug 17 20:46:16 2012
@@ -771,16 +771,14 @@ public final class Util {
    *  IntsRef. */
   public static IntsRef toUTF16(CharSequence s, IntsRef scratch) {
     final int charLimit = s.length();
+    scratch.offset = 0;
+    scratch.length = charLimit;
     scratch.grow(charLimit);
-    int idx = 0;
-    while(idx < charLimit) {
+    for (int idx = 0; idx < charLimit; idx++) {
       scratch.ints[idx] = (int) s.charAt(idx);
-      idx++;
     }
-    scratch.offset = 0;
-    scratch.length = idx;
     return scratch;
-  }
+  }    
 
   /** Decodes the Unicode codepoints from the provided
    *  CharSequence and places them in the provided scratch