>
> I guess for me the big question is what is trying to be accomplished here.
> With overlay types, it is pretty trivial to get "bare metal" JS maps, so it
> seems that this should be something more, with abstractions to make it more
> "Java-like" while not adding things which make it inefficient. I think it
> might be worthwhile to preserve Java equality semantics here by using the
> hash code as the key into the JS map, and managing collisions there.
> Something like:
>
> map = {hash1: [obj1, obj2, obj3], hash2: [obj4], hash3: [obj5, obj6]}
>
> That also gets you away from worring about keys colliding on different (or
> future) browsers, and you preserve Java equality semantics. Lookup should
> still be O(1) since hopefully collisions are rare, iteration is quick, etc.
> If a hash function is slow, it would be up to the hash function writer to
> cache the result in the object as is already best practice, rather than the
> Map implementation doing that automatically for them.
>
We can probably prototype different varieties. As it might be interesting to
implement one version using the algorithm above and see what the performance
characteristics are verses the expando-solution: as creating these classes
are dirt simple, what makes creating this API worthwhile is finding the
right dirt-simple implementation to use.
>
> One other suggestion -- I think rather than optimizing lots of puts in a
> row you want to allow a JSO to be passed to initialize the map. From my
> experience, simply having all the put calls is slow and takes up more space
> in the generated JS -- the primary way I improved NumberFormat's startup
> performance was by simply building a JSO directly with the data I needed
> rather than doing a bunch of puts into a map. So, for the users that will
> care abouot this, I think passing in a JSO to initialize the map will be a
> better choice.
>
That is a very interesting idea, as it seems to jive with the goal of
optimizing speed at the expense of API time.
> --
> John A. Tamplin
> Software Engineer (GWT), Google
>
> >
>
--
"There are only 10 types of people in the world: Those who understand
binary, and those who don't"
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---