vgritsenko    2004/01/08 21:08:23

  Modified:    java/src/org/apache/xindice/core/filer BTreeFiler.java
                        FSFiler.java HashFiler.java MemFiler.java
                        SizeableMemFiler.java
  Log:
  Optimize: key.equals("") is not cheap.
  
  Revision  Changes    Path
  1.20      +5 -5      
xml-xindice/java/src/org/apache/xindice/core/filer/BTreeFiler.java
  
  Index: BTreeFiler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/BTreeFiler.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- BTreeFiler.java   18 Dec 2003 15:05:20 -0000      1.19
  +++ BTreeFiler.java   9 Jan 2004 05:08:22 -0000       1.20
  @@ -137,7 +137,7 @@
       }
   
       public Record readRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return null;
           }
   
  @@ -165,7 +165,7 @@
       }
   
       public boolean writeRecord(Key key, Value value) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               throw new FilerException(FaultCodes.DBE_CANNOT_CREATE,
                                        "Invalid key: null or empty");
           }
  @@ -204,7 +204,7 @@
       }
   
       public boolean deleteRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return false;
           }
   
  
  
  
  1.16      +5 -5      
xml-xindice/java/src/org/apache/xindice/core/filer/FSFiler.java
  
  Index: FSFiler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/FSFiler.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- FSFiler.java      15 Aug 2003 03:08:36 -0000      1.15
  +++ FSFiler.java      9 Jan 2004 05:08:22 -0000       1.16
  @@ -180,7 +180,7 @@
       }
   
       public Record readRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return null;
           }
   
  @@ -212,7 +212,7 @@
       }
   
       public boolean writeRecord(Key key, Value value) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               throw new FilerException(FaultCodes.DBE_CANNOT_CREATE, "Invalid 
key: '" + key + "'");
           }
           if (value == null) {
  @@ -243,7 +243,7 @@
       }
   
       public boolean deleteRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return false;
           }
           checkOpened();
  
  
  
  1.20      +5 -5      
xml-xindice/java/src/org/apache/xindice/core/filer/HashFiler.java
  
  Index: HashFiler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/HashFiler.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- HashFiler.java    22 Dec 2003 01:38:42 -0000      1.19
  +++ HashFiler.java    9 Jan 2004 05:08:22 -0000       1.20
  @@ -164,7 +164,7 @@
       }
   
       public Record readRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return null;
           }
           checkOpened();
  @@ -242,7 +242,7 @@
   
       public boolean writeRecord(Key key, Value value) throws DBException {
           // Check that key is not larger than space on the page
  -        if (key == null || key.equals("") || key.getLength() > 
fileHeader.getPageSize() - fileHeader.getPageHeaderSize()) {
  +        if (key == null || key.getLength() == 0 || key.getLength() > 
fileHeader.getPageSize() - fileHeader.getPageHeaderSize()) {
               throw new FilerException(FaultCodes.DBE_CANNOT_CREATE, "Invalid 
key: '" + key + "'");
           }
           if (value == null) {
  @@ -273,7 +273,7 @@
       }
   
       public boolean deleteRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return false;
           }
           checkOpened();
  
  
  
  1.9       +5 -5      
xml-xindice/java/src/org/apache/xindice/core/filer/MemFiler.java
  
  Index: MemFiler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/MemFiler.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MemFiler.java     9 Aug 2003 18:56:18 -0000       1.8
  +++ MemFiler.java     9 Jan 2004 05:08:22 -0000       1.9
  @@ -150,7 +150,7 @@
       }
   
       public Record readRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return null;
           }
           checkOpened();
  @@ -158,7 +158,7 @@
       }
   
       public boolean writeRecord(Key key, Value value) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               throw new FilerException(FaultCodes.DBE_CANNOT_CREATE, "Invalid 
key: '" + key + "'");
           }
           if (value == null) {
  @@ -171,7 +171,7 @@
       }
   
       public boolean deleteRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return false;
           }
           checkOpened();
  
  
  
  1.5       +5 -5      
xml-xindice/java/src/org/apache/xindice/core/filer/SizeableMemFiler.java
  
  Index: SizeableMemFiler.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/SizeableMemFiler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SizeableMemFiler.java     9 Aug 2003 05:01:55 -0000       1.4
  +++ SizeableMemFiler.java     9 Jan 2004 05:08:23 -0000       1.5
  @@ -165,7 +165,7 @@
       }
   
       public Record readRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return null;
           }
           checkOpened();
  @@ -173,7 +173,7 @@
       }
   
       public boolean writeRecord(Key key, Value value) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               throw new FilerException(FaultCodes.DBE_CANNOT_CREATE, "Invalid 
key: '" + key + "'");
           }
           if (value == null) {
  @@ -186,7 +186,7 @@
       }
   
       public boolean deleteRecord(Key key) throws DBException {
  -        if (key == null || key.equals("")) {
  +        if (key == null || key.getLength() == 0) {
               return false;
           }
           checkOpened();
  
  
  

Reply via email to