PE> Actually, I've changed my mind about that. I don't think it is
PE> possible to reduce the timing of instructions within that loop,
PE> without causing an overrun. I was basically moving the testing
PE> before the move, and then special case after the loop, but the
PE> testing I was doing would destroy the register.
PE> HOWEVER, what could be done is if I give you the maximum length
PE> as WELL as just the '\n' terminator, then it could be written
PE> just as fast.
On the assumption that you are only concerned about not overrunning
the buffer, but besides that, you don't mind copying an extra
byte or three.
However, on closer reading of the ISO standard, I cannot see
anything that would allow me to do that. It says that characters
stop getting read when the newline character is read. What I
would have LIKED them to have said is "The contents of the
array after the newline character will be indeterminant". But
as it stands at the moment, people can instead be sure that their
array will not be clobbered with extra bytes, which means that
they can play silly buggers, and, e.g. do an fgets() and get
a line of BBBBBBBBBBBBBBBBBBBB and then an fgets and get a line
of AAAAAAA, and then clobber the '\n' with a C, knowing that
they will now get a AAAAAACBBBBBBBBBBBB, e.g.
What this means is that two halfword *stores* instead of a single
fullword store is unavoidable in the main loop. That also means
that there is no use in having the length available.
BFN. Paul.
@EOT:
---
* Origin: X (3:711/934.9)
|