This a nice optimization, and one certainly worth keeping in mind.   As
part of this transition, I'll be creating some more benchmarks on
performance, and might try it then to see if it makes any practical
difference.

          Thanks!

              Emily

On Mon, Oct 6, 2008 at 5:54 AM, Thomas Broyer <[EMAIL PROTECTED]> wrote:

>
> On 22 sep, 22:02, "Emily Crutcher" <[EMAIL PROTECTED]> wrote:
> > A more complete implementation of the event handlers has been added to
> > the gwt-incubator
> > gen2.event package<
> http://code.google.com/p/google-web-toolkit-incubator/source/browse/#...>.
>
> Implementation-detail note: why is DomEvent using getTypeInt()? Why
> not using getType()? It would save some string-to-int "translation"
> code (see issue 2927), and given that the value is only used as a key
> within DomEvent.WrappedKeyMap, I can't see a drawback (on the
> contrary: adding support for other "dom events" –e.g. drag'n'drop, cut/
> copy/paste, text selection, etc.– could then be done without the need
> to rewrite/overwrite this string-to-int mapping). Of course, the
> string-to-int mapping is still necessary for sinkEvents
> (addHandlerAndSink) to work, but it would be done at registration-time
> only, and not for every fired event!
> This means however, that DomEvent.Key has to keep track of both the
> int *and* the string event type (shouldn't this be somehow optimized
> by the JSStringInterner?), and that DomEvent-derived classes thus have
> to be kept "synchronized" with the getTypeInt()/sinkEvents() code (not
> a big deal, this is an almost-never-changing code).
>






>
> ...but there are some events that have different names (mousewheel/
> DOMMouseScroll). DomEvent.Key could have a register() abstract method
> (with register(String name) helper method), or variations along this
> line (e.g. constructor accepting an additional "String eventName" and
> calling register(eventName), for the common case, and ScrollEvent
> defining its own instance initializer code to call register() once
> more with the second name):
>
>  public abstract static class Key<EventType extends DomEvent,
> HandlerType extends EventHandler>
>      extends AbstractEvent.Key<EventType, HandlerType> {
>    int nativeEventType;
>
>    /**
>     * Creates a [EMAIL PROTECTED] Key}. Each event should have a singleton 
> key.
>     */
>    public Key(int nativeEventType) {
>      this.nativeEventType = nativeEventType;
>      register();
>    }
>
>    protected final void register(String eventName) {
>      registered.put(eventName, this);
>    }
>
>    protected abstract void register();
>
> ...
>
>
>  public static final Key<ScrollEvent, ScrollHandler> KEY = new new
> Key<ScrollEvent, ScrollHandler>(
>      Event.ONSCROLL) {
>    protected void register() {
>        register("mousewheel");
>        register("DOMMouseScroll");
>    }
>
>    @Override
>    protected void fire(ScrollHandler handler, ScrollEvent event) {
>      handler.onScroll(event);
>    }
>
>    @Override
>    public ScrollEvent wrap(Event nativeEvent) {
>      return new ScrollEvent(nativeEvent);
>    }
>  };
>



-- 
"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
-~----------~----~----~----~------~----~------~--~---

Reply via email to