vert-x3 / vertx-web

HTTP web applications for Vert.x
Apache License 2.0
1.11k stars 534 forks source link

Duplicated private static final TYPE_ARG properties in Rxified version of WebClient #1665

Open elR1co opened 4 years ago

elR1co commented 4 years ago

Questions

Is this normal to have so many duplicated private static final TYPE_ARG properties in Rxified version of WebClient ? There are 38 in version 3.9.1.

Version

3.9.x

3.8.5 is not impacted.

vietj commented 4 years ago

can you show the generated code ?

elR1co commented 4 years ago

In io.vertx.reactivex.ext.web.client.WebClient version 3.9.1 :

public static final TypeArg<WebClient> __TYPE_ARG = new TypeArg<>(    obj -> new WebClient((io.vertx.ext.web.client.WebClient) obj),
    WebClient::getDelegate
  );

private static final TypeArg<io.vertx.reactivex.core.buffer.Buffer> TYPE_ARG_0 = new TypeArg<io.vertx.reactivex.core.buffer.Buffer>(o1 -> io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate());
private static final TypeArg<io.vertx.reactivex.core.buffer.Buffer> TYPE_ARG_1 = new TypeArg<io.vertx.reactivex.core.buffer.Buffer>(o1 -> io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate());
private static final TypeArg<io.vertx.reactivex.core.buffer.Buffer> TYPE_ARG_2 = new TypeArg<io.vertx.reactivex.core.buffer.Buffer>(o1 -> io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate());
  ....
private static final TypeArg<io.vertx.reactivex.core.buffer.Buffer> TYPE_ARG_37 = new TypeArg<io.vertx.reactivex.core.buffer.Buffer>(o1 -> io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate());

public io.vertx.reactivex.ext.web.client.HttpRequest<io.vertx.reactivex.core.buffer.Buffer> request(io.vertx.core.http.HttpMethod method, int port, String host, String requestURI) { 
    io.vertx.reactivex.ext.web.client.HttpRequest<io.vertx.reactivex.core.buffer.Buffer> ret = io.vertx.reactivex.ext.web.client.HttpRequest.newInstance((io.vertx.ext.web.client.HttpRequest)delegate.request(method, port, host, requestURI), TYPE_ARG_0);
    return ret;
  }

public io.vertx.reactivex.ext.web.client.HttpRequest<io.vertx.reactivex.core.buffer.Buffer> request(io.vertx.core.http.HttpMethod method, io.vertx.reactivex.core.net.SocketAddress serverAddress, int port, String host, String requestURI) { 
    io.vertx.reactivex.ext.web.client.HttpRequest<io.vertx.reactivex.core.buffer.Buffer> ret = io.vertx.reactivex.ext.web.client.HttpRequest.newInstance((io.vertx.ext.web.client.HttpRequest)delegate.request(method, serverAddress.getDelegate(), port, host, requestURI), TYPE_ARG_1);
    return ret;
  }
...

In io.vertx.reactivex.ext.web.client.WebClient 3.8.5 :

public static final io.vertx.lang.rx.TypeArg<WebClient> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>(    obj -> new WebClient((io.vertx.ext.web.client.WebClient) obj),
    WebClient::getDelegate
  );

public io.vertx.reactivex.ext.web.client.HttpRequest<io.vertx.reactivex.core.buffer.Buffer> request(HttpMethod method, int port, String host, String requestURI) { 
    io.vertx.reactivex.ext.web.client.HttpRequest<io.vertx.reactivex.core.buffer.Buffer> ret = io.vertx.reactivex.ext.web.client.HttpRequest.newInstance(delegate.request(method, port, host, requestURI), (io.vertx.lang.rx.TypeArg)io.vertx.reactivex.core.buffer.Buffer.__TYPE_ARG);
    return ret;
  }

public io.vertx.reactivex.ext.web.client.HttpRequest<io.vertx.reactivex.core.buffer.Buffer> request(HttpMethod method, io.vertx.reactivex.core.net.SocketAddress serverAddress, int port, String host, String requestURI) { 
    io.vertx.reactivex.ext.web.client.HttpRequest<io.vertx.reactivex.core.buffer.Buffer> ret = io.vertx.reactivex.ext.web.client.HttpRequest.newInstance(delegate.request(method, serverAddress.getDelegate(), port, host, requestURI), (io.vertx.lang.rx.TypeArg)io.vertx.reactivex.core.buffer.Buffer.__TYPE_ARG);
    return ret;
  }
...
vietj commented 4 years ago

so that is normal because this is a fix for a bug, however we should try optimize that and reduce the number of type args (i.e group them).

On Sat, Jul 18, 2020 at 3:26 PM elR1co notifications@github.com wrote:

In WebClient version 3.9.1 :

public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new WebClient((io.vertx.ext.web.client.WebClient) obj), WebClient::getDelegate );

private static final TypeArg TYPE_ARG_0 = new TypeArg(o1 -> io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate()); private static final TypeArg TYPE_ARG_1 = new TypeArg(o1 -> io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate()); private static final TypeArg TYPE_ARG_2 = new TypeArg(o1 -> io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate()); .... private static final TypeArg TYPE_ARG_37 = new TypeArg(o1 -> io.vertx.reactivex.core.buffer.Buffer.newInstance((io.vertx.core.buffer.Buffer)o1), o1 -> o1.getDelegate());

public io.vertx.reactivex.ext.web.client.HttpRequest request(io.vertx.core.http.HttpMethod method, int port, String host, String requestURI) { io.vertx.reactivex.ext.web.client.HttpRequest ret = io.vertx.reactivex.ext.web.client.HttpRequest.newInstance((io.vertx.ext.web.client.HttpRequest)delegate.request(method, port, host, requestURI), TYPE_ARG_0); return ret; }

public io.vertx.reactivex.ext.web.client.HttpRequest request(io.vertx.core.http.HttpMethod method, io.vertx.reactivex.core.net.SocketAddress serverAddress, int port, String host, String requestURI) { io.vertx.reactivex.ext.web.client.HttpRequest ret = io.vertx.reactivex.ext.web.client.HttpRequest.newInstance((io.vertx.ext.web.client.HttpRequest)delegate.request(method, serverAddress.getDelegate(), port, host, requestURI), TYPE_ARG_1); return ret; } ...

In WebClient 3.8.5 :

public static final io.vertx.lang.rx.TypeArg __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new Buffer((io.vertx.core.buffer.Buffer) obj), Buffer::getDelegate );

public io.vertx.reactivex.ext.web.client.HttpRequest request(HttpMethod method, int port, String host, String requestURI) { io.vertx.reactivex.ext.web.client.HttpRequest ret = io.vertx.reactivex.ext.web.client.HttpRequest.newInstance(delegate.request(method, port, host, requestURI), (io.vertx.lang.rx.TypeArg)io.vertx.reactivex.core.buffer.Buffer.__TYPE_ARG); return ret; }

public io.vertx.reactivex.ext.web.client.HttpRequest request(HttpMethod method, io.vertx.reactivex.core.net.SocketAddress serverAddress, int port, String host, String requestURI) { io.vertx.reactivex.ext.web.client.HttpRequest ret = io.vertx.reactivex.ext.web.client.HttpRequest.newInstance(delegate.request(method, serverAddress.getDelegate(), port, host, requestURI), (io.vertx.lang.rx.TypeArg)io.vertx.reactivex.core.buffer.Buffer.__TYPE_ARG); return ret; } ...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vert-x3/vertx-web/issues/1665#issuecomment-660482815, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABXDCWFKUKXDLKMOFSGGQ3R4GPJFANCNFSM4O6WQ3RA .

elR1co commented 4 years ago

Sure. Actually I saw that during a profiling session. I was wondering if we were doing something wrong in our code, but then I compared with 3.8.5 version that we were using before, and I saw these differences.