vgritsenko    2004/01/06 19:57:52

  Modified:    java/src/org/apache/xindice/core/data Value.java
               java/src/org/apache/xindice/core Collection.java
  Log:
  optimization: reduce amount of calls to getData() as it has possibility of 
copying the data
  
  Revision  Changes    Path
  1.9       +11 -7     
xml-xindice/java/src/org/apache/xindice/core/data/Value.java
  
  Index: Value.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/data/Value.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Value.java        16 Dec 2003 14:06:10 -0000      1.8
  +++ Value.java        7 Jan 2004 03:57:52 -0000       1.9
  @@ -82,14 +82,14 @@
   
   
       public Value(Value value) {
  -        data = value.data;
  -        pos = value.pos;
  -        len = value.len;
  +        this.data = value.data;
  +        this.pos = value.pos;
  +        this.len = value.len;
       }
   
       public Value(byte[] data) {
           this.data = data;
  -        len = data.length;
  +        this.len = data.length;
       }
   
       public Value(byte[] data, int pos, int len) {
  @@ -153,9 +153,13 @@
           System.arraycopy(data, pos, tdata, tpos, len);
       }
   
  +    public final void copyTo(byte[] tdata, int tpos, int len) {
  +        System.arraycopy(data, pos, tdata, tpos, len);
  +    }
  +
       public final String toString() {
           try {
  -            return new String(getData(), "utf-8");
  +            return new String(data, pos, len, "utf-8");
           } catch (UnsupportedEncodingException e) {
               throw new XindiceRuntimeException("Java doesn't seem to support 
UTF-8!", e);
           }
  
  
  
  1.44      +3 -3      
xml-xindice/java/src/org/apache/xindice/core/Collection.java
  
  Index: Collection.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/Collection.java,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- Collection.java   25 Dec 2003 20:04:40 -0000      1.43
  +++ Collection.java   7 Jan 2004 03:57:52 -0000       1.44
  @@ -206,7 +206,7 @@
                   Record rec = set.getNextRecord();
                   Key key = rec.getKey();
                   Value val = rec.getValue();
  -                if (val.getData() != null) {
  +                if (val.getLength() > 0) {
                       try {
                           if (compressed) {
                               Document doc = new DocumentImpl(val.getData(), 
symbols, new NodeSource(Collection.this, key));
  
  
  

Reply via email to