tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/framework/src/org/apache/tapestry/parse SpecificationDigester.java
Date Fri, 21 Mar 2003 19:00:35 GMT
hlship      2003/03/21 11:00:34

  Modified:    framework/src/org/apache/tapestry/parse
                        SpecificationDigester.java
  Log:
  Optimize allocations of Locator objects while parsing specifications.
  
  Revision  Changes    Path
  1.2       +29 -8     jakarta-tapestry/framework/src/org/apache/tapestry/parse/SpecificationDigester.java
  
  Index: SpecificationDigester.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/org/apache/tapestry/parse/SpecificationDigester.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SpecificationDigester.java	15 Mar 2003 21:22:19 -0000	1.1
  +++ SpecificationDigester.java	21 Mar 2003 19:00:33 -0000	1.2
  @@ -67,6 +67,7 @@
   import org.xml.sax.Attributes;
   import org.xml.sax.Locator;
   import org.xml.sax.SAXException;
  +import org.xml.sax.XMLReader;
   
   /**
    *  Extension of {@link org.apache.commons.digester.Digester} with additional rules, hooks
  @@ -84,6 +85,10 @@
       private IResourceLocation _resourceLocation;
       private RegexpMatcher _matcher;
   
  +    private Location _lastLocation;
  +    private int _lastLine;
  +    private int _lastColumn;
  +
       /**
        *  Notifications are sent with the very first element.
        * 
  @@ -171,13 +176,26 @@
   
       public Location getLocationTag()
       {
  -        if (locator == null)
  -            return new Location(_resourceLocation);
  +        int line = -1;
  +        int column = -1;
  +
  +        if (locator != null)
  +        {
  +            line = locator.getLineNumber();
  +            column = locator.getColumnNumber();
  +        }
  +
  +        if (_lastLine != line || _lastColumn != column)
  +            _lastLocation = null;
   
  -        return new Location(
  -            _resourceLocation,
  -            locator.getLineNumber(),
  -            locator.getColumnNumber());
  +        if (_lastLocation == null)
  +        {
  +            _lastLine = line;
  +            _lastColumn = column;
  +            _lastLocation = new Location(_resourceLocation, line, column);
  +        }
  +
  +        return _lastLocation;
       }
   
       public IResourceLocation getResourceLocation()
  @@ -188,6 +206,10 @@
       public void setResourceLocation(IResourceLocation resourceLocation)
       {
           _resourceLocation = resourceLocation;
  +
  +        _lastLocation = null;
  +        _lastLine = -1;
  +        _lastColumn = -1;
       }
   
       public RegexpMatcher getMatcher()
  @@ -284,5 +306,4 @@
           }
   
       }
  -
   }
  
  
  

Mime
View raw message