SendBlock looks nice, it kinda allows guaranteed-packet-delivery
communication style. Especially nice if it's optimized for minimal overhead.
But after looking at the source I found that it has more of a clean but not
very optimal implementation:
procedure TBlockSocket.SendBlock(const Data: AnsiString);
var
i: integer;
begin
i := SwapBytes(Length(data));
SendString(Codelongint(i) + Data);
end;
First, the use of SendString. All it does is calling SendBuffer after a
typecast. Waste of cycles if the compiler decides not to inline.
What I don't like even more is "Codelongint(i) + Data". It forces a
reallocation and cloning of the the data string just to append 4 bytes! It's
not a big deal if we're dealing with 1KB packets, but what if I want to send
10MB this way?
I realize I could (and probably should) write my own optimized routines to
do the sending/receiving. It's just that I don't really see a good reason
for having a core library function with unnecesary reallocations of already
assembled data where a simple ref count increment would suffice.
Any comments?
Kipsus
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public