You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Petr Krajča <pk...@iol.cz> on 2004/06/05 12:18:00 UTC

removing multiple objects

hello,

i have small performance problem. if i remove multiple objects from document (about 300), it takes about half a minute. it seems to be a long time, because adding these objects takes just 4 seconds.
the code is something like this:

int cnt = list.size();
for (int i = 0; i < cnt; i++)
{
	Node e = (Node)list.get(i);
	if (e != null) e.getParentNode().removeChild(e);
}
		
list.clear();

i think this is caused by some rerendring or something like that. is there anyway howto make this code faster?

thanks for anything

petr krajca


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


Re: removing multiple objects

Posted by Robert Marcano <ro...@marcanoonline.com>.
On Sat, 2004-06-05 at 06:18, Petr Krajča wrote:
> hello,
> 
> i have small performance problem. if i remove multiple objects from document (about 300), it takes about half a minute. it seems to be a long time, because adding these objects takes just 4 seconds.
> the code is something like this:
> 
> int cnt = list.size();
> for (int i = 0; i < cnt; i++)
> {
> 	Node e = (Node)list.get(i);
> 	if (e != null) e.getParentNode().removeChild(e);
> }
> 		
> list.clear();

Are you running this code inside the update thread?

canvas.getUpdateManager().getUpdateRunnableQueue().
    invokeAndWait(new Runnable() {
        public void run() {
            // Insert some actions on the DOM here
        }
    });

> 
> i think this is caused by some rerendring or something like that. is there anyway howto make this code faster?
> 
> thanks for anything
> 
> petr krajca
-- 
Robert Marcano


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