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 2013/05/17 10:02:59 UTC

svn commit: r1483681 - in /lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util: BytesRef.java CharsRef.java IntsRef.java LongsRef.java

Author: dweiss
Date: Fri May 17 08:02:59 2013
New Revision: 1483681

URL: http://svn.apache.org/r1483681
Log:
Added javadocs to *Ref about clone() performing a shallow copy. I know, this is obvious and to be expected, but I fell a victim to this anyway, it's a damn thing to debug if you use clone() in hash maps etc. so perhaps it'll help somebody.

Modified:
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/BytesRef.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CharsRef.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/IntsRef.java
    lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/LongsRef.java

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/BytesRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/BytesRef.java?rev=1483681&r1=1483680&r2=1483681&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/BytesRef.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/BytesRef.java Fri May 17 08:02:59 2013
@@ -119,11 +119,17 @@ public final class BytesRef implements C
     }
   }
 
+  /**
+   * Returns a shallow clone of this instance (the underlying bytes are
+   * <b>not</b> copied and will be shared by both the returned object and this
+   * object.
+   * 
+   * @see #deepCopyOf
+   */
   @Override
   public BytesRef clone() {
     return new BytesRef(bytes, offset, length);
   }
-
   
   /** Calculates the hash code as required by TermsHash during indexing.
    * <p>It is defined as:

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CharsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CharsRef.java?rev=1483681&r1=1483680&r2=1483681&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CharsRef.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/CharsRef.java Fri May 17 08:02:59 2013
@@ -71,6 +71,13 @@ public final class CharsRef implements C
     this.length = chars.length;
   }
 
+  /**
+   * Returns a shallow clone of this instance (the underlying characters are
+   * <b>not</b> copied and will be shared by both the returned object and this
+   * object.
+   * 
+   * @see #deepCopyOf
+   */  
   @Override
   public CharsRef clone() {
     return new CharsRef(chars, offset, length);

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/IntsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/IntsRef.java?rev=1483681&r1=1483680&r2=1483681&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/IntsRef.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/IntsRef.java Fri May 17 08:02:59 2013
@@ -56,6 +56,13 @@ public final class IntsRef implements Co
     assert isValid();
   }
 
+  /**
+   * Returns a shallow clone of this instance (the underlying ints are
+   * <b>not</b> copied and will be shared by both the returned object and this
+   * object.
+   * 
+   * @see #deepCopyOf
+   */  
   @Override
   public IntsRef clone() {
     return new IntsRef(ints, offset, length);

Modified: lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/LongsRef.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/LongsRef.java?rev=1483681&r1=1483680&r2=1483681&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/LongsRef.java (original)
+++ lucene/dev/trunk/lucene/core/src/java/org/apache/lucene/util/LongsRef.java Fri May 17 08:02:59 2013
@@ -55,6 +55,13 @@ public final class LongsRef implements C
     assert isValid();
   }
 
+  /**
+   * Returns a shallow clone of this instance (the underlying longs are
+   * <b>not</b> copied and will be shared by both the returned object and this
+   * object.
+   * 
+   * @see #deepCopyOf
+   */  
   @Override
   public LongsRef clone() {
     return new LongsRef(longs, offset, length);