Re: [xml-dev] GrammarManager.getGrammar

Petr Kuzel <[email protected]> Sun, 01 Dec 2002 00:24:04 +0100
Newsgroups gmane.comp.java.netbeans.modules.xml.devel
Organization CollabNet Hosting
Message-ID <[email protected]>
Rich Unger wrote:

> Petr, the line you added to GrammarManager.getGrammar:
> 
> if (d == null) throw new IllegalArgumentException("null");
> 
> Seems to be throwing the exception when a file is first opened.  Could
> this be the key to the poor performance?

I eliminated several IAE by calling getGrammar conditionally after
I added the precondition check. Probably not all instances. But
it is easy to eliminate them as the are manifested very aggressively.
Yes, IAE can easily cause performance regression.
 
> BTW, when I replaced it with a silent failure:
> 
> if (d == null ) return null
> 
> and checked for nulls whenever I call getGrammar(), it worked fine.  I
> didn't check it in, though, because I think your code is better, and
> just returning null is covering up some other problem.

Exactly.
 
> All the getGrammar() requests come from ElementNode (or stuff called
> by ElementNode).  If there is some laziness in binding the ElementNode
> to its owner DataObject, how can we force the binding when asking for
> a grammar?

Either eliminate the laziness or balk binding efforts until DO is
associated. I'm afraid that laziness will never be eliminated as
whole editor stuff can exist without associated DO (e.g. new nodes
until added into existing tree). The second approach seems right to me.

  Cc.