which one is faster?

L

luca

I have an HashMap which contains data to fulfill requests
in my servlet. I have two alternatives:

- create a new HashMap for each request

- reuse the same HashMap, but I'll have to reset it
at the end of each request to make sure it's clean for the
next round.

which approach is more efficient?

Notes:
it's not really a servlet. It's a custom tag to be used in JSP.
Is there a method to clean a HashMap?

thanks

luca
 
W

William Brogden

luca said:
I have an HashMap which contains data to fulfill requests
in my servlet. I have two alternatives:

- create a new HashMap for each request

- reuse the same HashMap, but I'll have to reset it
at the end of each request to make sure it's clean for the
next round.

which approach is more efficient?

Notes:
it's not really a servlet. It's a custom tag to be used in JSP.
Is there a method to clean a HashMap?

thanks

luca

Creation is so fast that I doubt you could measure the difference,
especially in a JSP environment with all the character output
going on.
Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top