Re: Efficient scather-gather-copy



"Mark Whitlock" <spamtrap@xxxxxxxxxx> writes:

I'm in the unlucky situation to convert mails from the
"\n"-lineendings to "\r\n"-ones.
You shod probably just run these through a filter program. What
OS are you using ?

It's UNIX and yet filtering is simply too slow. I'd rather use memcpy()
than external programs.

If I'm not mistaken, I have to count the lines, alloc
sizeof(mail)+num_of_lines(mail), copy each line seperately with a space
between them to the buffer and replace the "\n" through "\r\n".
How about opening 2 files ,one for input ,one for output.
Read the input ,if it is not a newline ,write it to the output.
If it is a newline ,write return ,then newline to the output.

Well, I'm getting it as a buffer and anything that remotely could
involve access to file systems is out of question.

Imagine dozens of mails per _second_ that want to be
processed. Probably, memcpy() might be fast enough on a decent machine,
however it would definitely be a bottleneck. So I want to make it really
as fast a possible, as there isn't unfortunately much I can optimize
algorithm-sided.

This should stream pretty fast.
probably missing something,

Only, that "pretty fast" ain't "fast enough" in this case. ;)

Thanks for your reply,
-hs

.



Relevant Pages

  • Re: Efficient scather-gather-copy
    ... You shod probably just run these through a filter program. ... I can't see that memcpy() would buy you much here, ... Read the input,if it is not a newline,write it to the output. ... In order to allocthe buffer you need, ...
    (comp.lang.asm.x86)
  • Re: Efficient scather-gather-copy
    ... I'm in the unlucky situation to convert mails from the "\n"-lineendings ... You shod probably just run these through a filter program. ... Read the input,if it is not a newline,write it to the output. ...
    (comp.lang.asm.x86)