Optimize the code to not call StrToBuf when DataLength is 0.