xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From daver...@apache.org
Subject cvs commit: xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store Cursor.java CursorData.java Saver.java Splay.java
Date Fri, 14 May 2004 00:00:58 GMT
daveremy    2004/05/13 17:00:58

  Modified:    v1/src/common/org/apache/xmlbeans/impl/common XPath.java
               v1/src/typeimpl/org/apache/xmlbeans/impl/schema
                        SchemaAttributeModelImpl.java
                        SchemaGlobalElementImpl.java SchemaTypeImpl.java
                        SchemaTypeLoaderImpl.java
                        StscSimpleTypeResolver.java
               v1/src/typeimpl/org/apache/xmlbeans/impl/values
                        XmlListImpl.java
               v1/src/xmlcomp/org/apache/xmlbeans/impl/tool
                        BaseSchemaResourceManager.java CommandLine.java
               v1/src/xmlpublic/org/apache/xmlbeans QNameSetBuilder.java
               v1/src/xmlstore/org/apache/xmlbeans/impl/store Cursor.java
                        CursorData.java Saver.java Splay.java
  Log:
  contributed by Kevin Krouse
  - save some time on List.toArray() by passing in a new array of the right size
  - release the Root that is being held by CursorData
  
  DRTs: pass
  
  Revision  Changes    Path
  1.4       +2 -2      xml-xmlbeans/v1/src/common/org/apache/xmlbeans/impl/common/XPath.java
  
  Index: XPath.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/common/org/apache/xmlbeans/impl/common/XPath.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XPath.java	12 Feb 2004 20:05:54 -0000	1.3
  +++ XPath.java	14 May 2004 00:00:57 -0000	1.4
  @@ -831,7 +831,7 @@
               while ( tokenize( "|" ) )
                   tokenizePath( paths );
   
  -            return new Selector( (Step[]) paths.toArray( new Step [ 0 ] ) );
  +            return new Selector( (Step[]) paths.toArray( new Step [ paths.size() ] ) );
           }
   
           private XPath tokenizeXPath ( ) throws XPathCompileException
  @@ -997,4 +997,4 @@
   
       private final Selector _selector;
       private final boolean  _sawDeepDot;
  -}
  \ No newline at end of file
  +}
  
  
  
  1.4       +5 -1      xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeModelImpl.java
  
  Index: SchemaAttributeModelImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaAttributeModelImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SchemaAttributeModelImpl.java	12 Feb 2004 20:05:55 -0000	1.3
  +++ SchemaAttributeModelImpl.java	14 May 2004 00:00:58 -0000	1.4
  @@ -66,7 +66,11 @@
   
       public SchemaLocalAttribute[] getAttributes()
       {
  -        return (SchemaLocalAttribute[])attrMap.values().toArray(EMPTY_SLA_ARRAY);
  +        if (attrMap.values().size() == 0)
  +            return EMPTY_SLA_ARRAY;
  +
  +        SchemaLocalAttribute[] data = new SchemaLocalAttribute[attrMap.values().size()];
  +        return (SchemaLocalAttribute[])attrMap.values().toArray(data);
       }
   
       public SchemaLocalAttribute getAttribute(QName name)
  
  
  
  1.4       +4 -2      xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaGlobalElementImpl.java
  
  Index: SchemaGlobalElementImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaGlobalElementImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SchemaGlobalElementImpl.java	12 Feb 2004 20:05:55 -0000	1.3
  +++ SchemaGlobalElementImpl.java	14 May 2004 00:00:58 -0000	1.4
  @@ -27,8 +27,8 @@
   public class SchemaGlobalElementImpl extends SchemaLocalElementImpl
           implements SchemaGlobalElement
   {
  +    private static final QName[] EMPTY_QNAME_ARRAY = new QName[0];
       private Set _sgMembers = new LinkedHashSet();
  -    private static final QName[] _namearray = new QName[0];
       private boolean _finalExt;
       private boolean _finalRest;
       private SchemaTypeSystem _typeSystem;
  @@ -80,7 +80,9 @@
   
       public QName[] substitutionGroupMembers()
       {
  -        return (QName[])_sgMembers.toArray(_namearray);
  +        if (_sgMembers.size() == 0)
  +            return EMPTY_QNAME_ARRAY;
  +        return (QName[])_sgMembers.toArray(new QName[_sgMembers.size()]);
       }
   
       public void addSubstitutionGroupMember(QName name)
  
  
  
  1.10      +4 -0      xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java
  
  Index: SchemaTypeImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeImpl.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SchemaTypeImpl.java	27 Apr 2004 00:19:23 -0000	1.9
  +++ SchemaTypeImpl.java	14 May 2004 00:00:58 -0000	1.10
  @@ -643,6 +643,8 @@
           List list = new ArrayList();
           list.addAll(_propertyModelByElementName.values());
           list.addAll(_propertyModelByAttributeName.values());
  +        if (list.size()==0)
  +            return NO_PROPERTIES;
           return (SchemaProperty[])list.toArray(new SchemaProperty[list.size()]);
       }
   
  @@ -687,6 +689,8 @@
   
           }
   
  +        if (results.size() == 0)
  +            return NO_PROPERTIES;
           return (SchemaProperty[])results.toArray(new SchemaProperty[results.size()]);
       }
   
  
  
  
  1.6       +3 -1      xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java
  
  Index: SchemaTypeLoaderImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeLoaderImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SchemaTypeLoaderImpl.java	16 Mar 2004 00:04:36 -0000	1.5
  +++ SchemaTypeLoaderImpl.java	14 May 2004 00:00:58 -0000	1.6
  @@ -131,7 +131,9 @@
   
           private SchemaTypeLoader[] toArray()
           {
  -            return (SchemaTypeLoader[])theList.toArray(EMPTY_SCHEMATYPELOADER_ARRAY);
  +            if (theList.size() == 0)
  +                return EMPTY_SCHEMATYPELOADER_ARRAY;
  +            return (SchemaTypeLoader[])theList.toArray(new SchemaTypeLoader[theList.size()]);
           }
       }
   
  
  
  
  1.4       +11 -6     xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java
  
  Index: StscSimpleTypeResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/schema/StscSimpleTypeResolver.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- StscSimpleTypeResolver.java	12 Feb 2004 20:05:55 -0000	1.3
  +++ StscSimpleTypeResolver.java	14 May 2004 00:00:58 -0000	1.4
  @@ -813,8 +813,8 @@
                           break;
   
                       case SchemaType.FACET_PATTERN:
  -                        org.apache.xmlbeans.impl.regex.RegularExpression p;
  -                        try { p = new org.apache.xmlbeans.impl.regex.RegularExpression(facet.getValue().getStringValue(),
"X"); }
  +                        RegularExpression p;
  +                        try { p = new RegularExpression(facet.getValue().getStringValue(),
"X"); }
                           catch (org.apache.xmlbeans.impl.regex.ParseException e)
                           {
                               state.error("Malformed regular expression", XmlErrorContext.FACET_VALUE_MALFORMED,
facet);
  @@ -857,11 +857,16 @@
           }
   
           // store the pattern list
  -        org.apache.xmlbeans.impl.regex.RegularExpression[] patternArray;
  -        if (patterns != null)
  -            patternArray = (org.apache.xmlbeans.impl.regex.RegularExpression[])patterns.toArray(EMPTY_REGEX_ARRAY);
  +        RegularExpression[] patternArray;
  +        if (patterns != null && patterns.size() != 0)
  +        {
  +            patternArray = new RegularExpression[patterns.size()];
  +            patterns.toArray(patternArray);
  +        }
           else
  +        {
               patternArray = EMPTY_REGEX_ARRAY;
  +        }
           sImpl.setPatternFacet((patternArray.length > 0 || baseImpl.hasPatternFacet()));
           sImpl.setPatterns(patternArray);
       }
  @@ -874,7 +879,7 @@
           return result;
       }
   
  -    private static final org.apache.xmlbeans.impl.regex.RegularExpression[] EMPTY_REGEX_ARRAY
= new org.apache.xmlbeans.impl.regex.RegularExpression[0];
  +    private static final RegularExpression[] EMPTY_REGEX_ARRAY = new RegularExpression[0];
   
       private static boolean isDiscreteType(SchemaTypeImpl sImpl)
       {
  
  
  
  1.4       +5 -1      xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/values/XmlListImpl.java
  
  Index: XmlListImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/typeimpl/org/apache/xmlbeans/impl/values/XmlListImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XmlListImpl.java	12 Feb 2004 20:05:57 -0000	1.3
  +++ XmlListImpl.java	14 May 2004 00:00:58 -0000	1.4
  @@ -123,7 +123,11 @@
               while (i < s.length() && XMLChar.isSpace(s.charAt(i)))
                   i += 1;
               if (i >= s.length())
  -                return (String[])result.toArray(EMPTY_STRINGARRAY);
  +            {
  +                if (result.size() == 0)
  +                    return EMPTY_STRINGARRAY;
  +                return (String[])result.toArray(new String[result.size()]);
  +            }
               start = i;
               while (i < s.length() && !XMLChar.isSpace(s.charAt(i)))
                   i += 1;
  
  
  
  1.6       +3 -2      xml-xmlbeans/v1/src/xmlcomp/org/apache/xmlbeans/impl/tool/BaseSchemaResourceManager.java
  
  Index: BaseSchemaResourceManager.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlcomp/org/apache/xmlbeans/impl/tool/BaseSchemaResourceManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BaseSchemaResourceManager.java	13 Apr 2004 17:06:13 -0000	1.5
  +++ BaseSchemaResourceManager.java	14 May 2004 00:00:58 -0000	1.6
  @@ -125,7 +125,8 @@
               syncCacheWithLocalXsdFiles(allFilenames, false);
   
           SchemaResource[] starters = (SchemaResource[])
  -                _resourceForFilename.values().toArray(new SchemaResource[0]);
  +                _resourceForFilename.values().toArray(
  +                    new SchemaResource[_resourceForFilename.values().size()]);
   
           if (refresh)
               redownloadEntries(starters);
  @@ -169,7 +170,7 @@
           }
   
           SchemaResource[] starters = (SchemaResource[])
  -               starterset.toArray(new SchemaResource[0]);
  +               starterset.toArray(new SchemaResource[starterset.size()]);
   
           if (refresh)
               redownloadEntries(starters);
  
  
  
  1.4       +5 -2      xml-xmlbeans/v1/src/xmlcomp/org/apache/xmlbeans/impl/tool/CommandLine.java
  
  Index: CommandLine.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlcomp/org/apache/xmlbeans/impl/tool/CommandLine.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CommandLine.java	12 Feb 2004 20:06:00 -0000	1.3
  +++ CommandLine.java	14 May 2004 00:00:58 -0000	1.4
  @@ -142,7 +142,10 @@
   
       public File[] getFiles()
       {
  -        return (File[])getFileList().toArray(EMPTY_FILEARRAY);
  +        int size = getFileList().size();
  +        if (size == 0)
  +            return EMPTY_FILEARRAY;
  +        return (File[])getFileList().toArray(new File[size]);
       }
   
       public File getBaseDir()
  @@ -159,6 +162,6 @@
               if (f.getName().endsWith(ext))
                   result.add(f);
           }
  -        return (File[])result.toArray(EMPTY_FILEARRAY);
  +        return (File[])result.toArray(new File[result.size()]);
       }
   }
  
  
  
  1.4       +5 -1      xml-xmlbeans/v1/src/xmlpublic/org/apache/xmlbeans/QNameSetBuilder.java
  
  Index: QNameSetBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlpublic/org/apache/xmlbeans/QNameSetBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- QNameSetBuilder.java	12 Feb 2004 20:06:01 -0000	1.3
  +++ QNameSetBuilder.java	14 May 2004 00:00:58 -0000	1.4
  @@ -195,7 +195,11 @@
               while (i < s.length() && isSpace(s.charAt(i)))
                   i += 1;
               if (i >= s.length())
  -                return (String[])result.toArray(EMPTY_STRINGARRAY);
  +            {
  +                if (result.size()==0)
  +                    return EMPTY_STRINGARRAY;
  +                return (String[])result.toArray(new String[result.size()]);
  +            }
               start = i;
               while (i < s.length() && !isSpace(s.charAt(i)))
                   i += 1;
  
  
  
  1.10      +1 -1      xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Cursor.java
  
  Index: Cursor.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Cursor.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Cursor.java	2 Apr 2004 02:02:15 -0000	1.9
  +++ Cursor.java	14 May 2004 00:00:58 -0000	1.10
  @@ -131,7 +131,7 @@
           {
               if (!isDisposed())
               {
  -                _data.release();
  +                _data.release(true);
                   _data = null;
               }
           }
  
  
  
  1.2       +10 -7     xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/CursorData.java
  
  Index: CursorData.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/CursorData.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CursorData.java	16 Mar 2004 00:04:36 -0000	1.1
  +++ CursorData.java	14 May 2004 00:00:58 -0000	1.2
  @@ -46,7 +46,7 @@
       private static ThreadLocal tl_CachedCursorData =
           new ThreadLocal() { protected Object initialValue() { return new ArrayList(); }
};
       
  -    protected void release ( )
  +    protected void release ( boolean cache )
       {
           if (_goober.getSplay() != null)
           {
  @@ -55,12 +55,15 @@
               if (_stack != null)
                   _stack.dispose();
   
  -            _goober.set( null, 0 );
  +            _goober.release();
               
  -            ArrayList dataCache = (ArrayList) tl_CachedCursorData.get();
  +            if (cache)
  +            {
  +                ArrayList dataCache = (ArrayList) tl_CachedCursorData.get();
   
  -            if (dataCache.size() < 128)
  -                dataCache.add( this );
  +                if (dataCache.size() < 128)
  +                    dataCache.add( this );
  +            }
           }
       }
       
  @@ -72,7 +75,7 @@
           {
               synchronized ( _goober.getRoot() )
               {
  -                release();
  +                release(false);
               }
           }
       }
  @@ -91,4 +94,4 @@
   
       protected Cursor.Selections  _selections;
       protected int                _currentSelection;
  -}
  \ No newline at end of file
  +}
  
  
  
  1.9       +8 -5      xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Saver.java
  
  Index: Saver.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Saver.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Saver.java	3 Mar 2004 22:56:38 -0000	1.8
  +++ Saver.java	14 May 2004 00:00:58 -0000	1.9
  @@ -97,10 +97,6 @@
           _attrNames = new HashSet();
           _firstPush = true;
           
  -        _newLine = System.getProperty( "line.separator" );
  -
  -        if (_newLine == null)
  -            _newLine = "\n";
   
           // Initialize the state of the namespaces
           _namespaceStack = new ArrayList();
  @@ -4744,5 +4740,12 @@
       private String  _filterProcinst;
       private Map     _suggestedPrefixes;
   
  -    protected String  _newLine;
  +    protected static String  _newLine;
  +
  +    static
  +    {
  +        _newLine = System.getProperty( "line.separator" );
  +        if (_newLine == null)
  +            _newLine = "\n";
  +    }
   }
  
  
  
  1.6       +6 -0      xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Splay.java
  
  Index: Splay.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v1/src/xmlstore/org/apache/xmlbeans/impl/store/Splay.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Splay.java	12 Feb 2004 20:06:04 -0000	1.5
  +++ Splay.java	14 May 2004 00:00:58 -0000	1.6
  @@ -3876,6 +3876,12 @@
               doSet( r, null, 0 );
           }
   
  +        void release ( )
  +        {
  +            set( null, 0);
  +            _root = null;
  +        }
  +
           private final void append ( Splay s )
           {
               assert s != null;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message