November 21, 2020 How Performance down slow it is using UFCS friendly function? | ||||
---|---|---|---|---|
| ||||
// Função receive() char[] receive(Socket socket, int size = 8192) nothrow { try { char[] buffer; buffer.length = size; int rq = socket.receive(buffer); return buffer[0..rq]; } catch(Throwable){return null;} } s = new Socket(AddressFamily.INET, SocketType.STREAM); writeln(s.receive(8192)); // How slow is using as friendly function? |
November 21, 2020 Re: How Performance down slow it is using UFCS friendly function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcone | On Saturday, 21 November 2020 at 00:26:03 UTC, Marcone wrote:
> // Função receive()
> char[] receive(Socket socket, int size = 8192) nothrow {
> try {
> char[] buffer;
> buffer.length = size;
> int rq = socket.receive(buffer);
> return buffer[0..rq];
> } catch(Throwable){return null;}
> }
>
>
> s = new Socket(AddressFamily.INET, SocketType.STREAM);
> writeln(s.receive(8192)); // How slow is using as friendly function?
Calling a function with or without UFCS makes absolutely no difference to performance. The compiler will generate the exact same code whether you write `receive(s, 8192)` or `s.receive(8192)`.
|
Copyright © 1999-2021 by the D Language Foundation