The main difference between reset() and resetOrCopy() is that the
former is a public API for the application to explicitly tell the
parser that it is done with the results of the last parse.  The
latter is called when the parser does not know this and must assume
that any previous parse results are still "live".  However, it is
possible that a given component of the parser might actually be
keeping track and may know that it has not been used since the last
reset and does not need to be "replaced".  So for resetOrCopy, a
component can use its old innards if it is safe to do so, or replace
them if it is not.  When reset() is called, the component can reuse
it's old innards even if it knows they are "dirty".

The idea behind all this, but was never really implemented well
(never got to it), was to make the work of "parse(); parse();" be
as little as necessary to be safe, and to make "parse(); reset();
parse();" be much faster when the application knows that the previous
document data has been used and is no longer "live".

Hope this helps,  The short answer to your question is that when
someone calls reset() on a parser, they better be done with the old
parse data, because the parser will clobber it during the next
parse.  Since the resetOrCopy() call that you mention will only be
called when reset() is not called, the parser has to assume that the
application might still be referencing data from a parse.  A good
example of this is the deferred DOM implementation.  It would be
quite a surprise if someone references a value in a DOM tree after
parse() has been called to create a different document and to get
strings from that document string pool instead of the one used when
the original document that created the DOM tree was parsed.

Regards,
Glenn




                                                                                       
                                    
                    Robin                                                              
                                    
                    Tanenbaum/Poughkeepsie       To:     [EMAIL PROTECTED]   
                                    
                    /IBM@IBMUS                   cc:                                   
                                    
                                                 Subject:     Use of reset instead of 
resetOrCopy when re-using parsers    
                    07/25/2001 08:48 AM                                                
                                    
                    Please respond to                                                  
                                    
                    xerces-j-dev                                                       
                                    
                                                                                       
                                    
                                                                                       
                                    



When a parser is re-used the parseSomeSetup method in
org.apache.xerces.framework.XMLParser calls resetOrCopy().  ResetOrCopy is
so expensive, there is minimal benefit from reusing the parser.   I would
prefer to use the lighter weight reset() method provided in XMLParser.  Is
there any reason to avoid the reset() method?  Will it always safely
prepare the parser for re-use or are there circumstances which it should be
avoided?

Thanks,
Robin


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to