You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Sandro Martini <sa...@gmail.com> on 2009/08/03 17:28:07 UTC

little performance enhancement on WTKXSerializer

Hi to all,
take a look at this, taken from WTKXSerializer (inside its inner class
NamedObjectBindings):

        public void putAll(Map<? extends String, ? extends Object> map) {
// original
//            for (String key : map.keySet()) {
//                put(key, map.get(key));
//            }
// TODO: new, test before ...
            Set<? extends Map.Entry<? extends String, ? extends
Object>> set = map.entrySet();
            for (Map.Entry<? extends String, ? extends Object> entry : set) {
            	put(entry.getKey(), entry.getValue());
            }

        }


What do you think ?
The original version is ok, but doesn't use the (more efficient)
entrySet of Map, maybe useful as a reference also for other parts in
sources ...
I'm sorry but at the moment I have tried only to run some of tests, al
all seems to work, but maybe some deeper tests are required here.

Part of this Generics trick is taken from here:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231312


Tell me something.

Bye,
Sandro

Re: little performance enhancement on WTKXSerializer

Posted by Greg Brown <gk...@mac.com>.
The method he is referring to is actually in WTKXSerializer and  
unfortunately needs to continue to use java.util.Map. But it is not a  
method that will be called very often, if ever.


On Aug 4, 2009, at 7:04 AM, Todd Volkert wrote:

> Yeah, separating it from the java.util.Map is on the list of things  
> to get
> done for 1.3 though.
>
> On Tue, Aug 4, 2009 at 3:19 AM, Sandro Martini <sandro.martini@gmail.com 
> >wrote:
>
>> Hi,
>> but that method uses a standard java.util.Map ... as seen in imports,
>> so Findbugs said to me the trick.
>>
>>       public void putAll(Map<? extends String, ? extends Object>  
>> map) {
>>
>> But i agree with you, it's not a problem ...
>>
>> Bye
>>


Re: little performance enhancement on WTKXSerializer

Posted by Todd Volkert <tv...@gmail.com>.
Yeah, separating it from the java.util.Map is on the list of things to get
done for 1.3 though.

On Tue, Aug 4, 2009 at 3:19 AM, Sandro Martini <sa...@gmail.com>wrote:

> Hi,
> but that method uses a standard java.util.Map ... as seen in imports,
> so Findbugs said to me the trick.
>
>        public void putAll(Map<? extends String, ? extends Object> map) {
>
> But i agree with you, it's not a problem ...
>
> Bye
>

Re: little performance enhancement on WTKXSerializer

Posted by Sandro Martini <sa...@gmail.com>.
Hi,
but that method uses a standard java.util.Map ... as seen in imports,
so Findbugs said to me the trick.

        public void putAll(Map<? extends String, ? extends Object> map) {

But i agree with you, it's not a problem ...

Bye

Re: little performance enhancement on WTKXSerializer

Posted by Greg Brown <gk...@mac.com>.
Pivot's Map interface performs iteration differently, so this  
technique doesn't really apply to Pivot in general.

On Aug 3, 2009, at 12:42 PM, Sandro Martini wrote:

> Ok, i would be useful as a reference for using the same trick also on
> other Maps (with generics and wildcards, etc), so at least I'd think
> to keep this commented, but no problem if you want to remove it.
>
> Bye,
> Sandro


Re: little performance enhancement on WTKXSerializer

Posted by Sandro Martini <sa...@gmail.com>.
Ok, i would be useful as a reference for using the same trick also on
other Maps (with generics and wildcards, etc), so at least I'd think
to keep this commented, but no problem if you want to remove it.

Bye,
Sandro

Re: little performance enhancement on WTKXSerializer

Posted by Greg Brown <gk...@mac.com>.
I wouldn't worry about this one. This method won't be called very  
often, and isn't likely to contain much data even when it is.

On Aug 3, 2009, at 11:28 AM, Sandro Martini wrote:

> Hi to all,
> take a look at this, taken from WTKXSerializer (inside its inner class
> NamedObjectBindings):
>
>        public void putAll(Map<? extends String, ? extends Object>  
> map) {
> // original
> //            for (String key : map.keySet()) {
> //                put(key, map.get(key));
> //            }
> // TODO: new, test before ...
>            Set<? extends Map.Entry<? extends String, ? extends
> Object>> set = map.entrySet();
>            for (Map.Entry<? extends String, ? extends Object>  
> entry : set) {
>            	put(entry.getKey(), entry.getValue());
>            }
>
>        }
>
>
> What do you think ?
> The original version is ok, but doesn't use the (more efficient)
> entrySet of Map, maybe useful as a reference also for other parts in
> sources ...
> I'm sorry but at the moment I have tried only to run some of tests, al
> all seems to work, but maybe some deeper tests are required here.
>
> Part of this Generics trick is taken from here:
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231312
>
>
> Tell me something.
>
> Bye,
> Sandro