You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/05/14 07:14:28 UTC
cvs commit: xml-xalan/java/src/org/apache/xml/dtm DTMStringPool.java
sboag 01/05/13 22:14:28
Modified: java/src/org/apache/xml/dtm Tag: DTM_EXP DTMStringPool.java
Log:
In the constructor, do stringToIndex("") to force empty strings to be index 0.
This helps to quickly determine empty strings, and to make "" vs.
null a little easier.
Revision Changes Path
No revision
No revision
1.1.2.5 +41 -38 xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMStringPool.java
Index: DTMStringPool.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/Attic/DTMStringPool.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- DTMStringPool.java 2001/05/11 21:28:30 1.1.2.4
+++ DTMStringPool.java 2001/05/14 05:14:27 1.1.2.5
@@ -101,13 +101,16 @@
m_intToString=new Vector();
m_hashChain=new IntVector();
removeAllElements();
+
+ // -sb Add this to force empty strings to be index 0.
+ stringToIndex("");
}
public void removeAllElements()
{
m_intToString.removeAllElements();
for(int i=0;i<HASHPRIME;++i)
- m_hashStart[i]=NULL;
+ m_hashStart[i]=NULL;
m_hashChain.removeAllElements();
}
@@ -134,13 +137,13 @@
int hashlast=m_hashStart[hashslot];
int hashcandidate=hashlast;
while(hashcandidate!=NULL)
- {
- if(m_intToString.elementAt(hashcandidate).equals(s))
- return hashcandidate;
-
- hashlast=hashcandidate;
- hashcandidate=m_hashChain.elementAt(hashcandidate);
- }
+ {
+ if(m_intToString.elementAt(hashcandidate).equals(s))
+ return hashcandidate;
+
+ hashlast=hashcandidate;
+ hashcandidate=m_hashChain.elementAt(hashcandidate);
+ }
// New value. Add to tables.
int newIndex=m_intToString.size();
@@ -148,9 +151,9 @@
m_hashChain.addElement(NULL); // Initialize to no-following-same-hash
if(hashlast==NULL) // First for this hash
- m_hashStart[hashslot]=newIndex;
+ m_hashStart[hashslot]=newIndex;
else // Link from previous with same hash
- m_hashChain.setElementAt(newIndex,hashlast);
+ m_hashChain.setElementAt(newIndex,hashlast);
return newIndex;
}
@@ -178,35 +181,35 @@
for(int pass=0;pass<=1;++pass)
{
- int i;
+ int i;
- for(i=0;i<word.length;++i)
- {
- int j=pool.stringToIndex(word[i]);
- if(j!=i)
- System.out.println("\tMismatch populating pool: assigned "+
- j+" for create "+i);
- }
-
- for(i=0;i<word.length;++i)
- {
- int j=pool.stringToIndex(word[i]);
- if(j!=i)
- System.out.println("\tMismatch in stringToIndex: returned "+
- j+" for lookup "+i);
- }
-
- for(i=0;i<word.length;++i)
- {
- String w=pool.indexToString(i);
- if(!word[i].equals(w))
- System.out.println("\tMismatch in indexToString: returned"+
- w+" for lookup "+i);
- }
-
- pool.removeAllElements();
-
- System.out.println("\nPass "+pass+" complete\n");
+ for(i=0;i<word.length;++i)
+ {
+ int j=pool.stringToIndex(word[i]);
+ if(j!=i)
+ System.out.println("\tMismatch populating pool: assigned "+
+ j+" for create "+i);
+ }
+
+ for(i=0;i<word.length;++i)
+ {
+ int j=pool.stringToIndex(word[i]);
+ if(j!=i)
+ System.out.println("\tMismatch in stringToIndex: returned "+
+ j+" for lookup "+i);
+ }
+
+ for(i=0;i<word.length;++i)
+ {
+ String w=pool.indexToString(i);
+ if(!word[i].equals(w))
+ System.out.println("\tMismatch in indexToString: returned"+
+ w+" for lookup "+i);
+ }
+
+ pool.removeAllElements();
+
+ System.out.println("\nPass "+pass+" complete\n");
} // end pass loop
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org