I started with this for the right arrow:
*curPosition += (*curPosition < fieldLength);
However, this did not work for shifting over the offset value. With that in mind, I attempted something along the lines of this:
*curPosition < fieldLength ? *curPosition++ : (*strOffset += (*strOffset < fieldLength));
Well, Let's just say this code did not work at all! Once it reached the end of the fieldLength the cursor would never move back. I'm sure it has something to do with it being an else case rather than an else if. Anyway, I don't think it would be any faster than the regular format. I then dropped that idea all together and went with a more simple approach. Here it is:
*curPosition += (*curPosition < fieldLength); *strOffset += (*curPosition == fieldLength) && (*strOffset < fieldLength);
I might be able to refine it some more. Maybe even get it on one line, but for now I think it looks much more awesome.
No comments:
Post a Comment