char[] to hex string exercise

前端 未结 16 739
感情败类
感情败类 2021-01-12 19:14

Below is my current char* to hex string function. I wrote it as an exercise in bit manipulation. It takes ~7ms on a AMD Athlon MP 2800+ to hexify a 10 million byte array. Is

16条回答
  •  迷失自我
    2021-01-12 20:13

    For one, instead of multiplying by 16 do a bitshift << 4

    Also don't use the std::string, instead just create a buffer on the heap and then delete it. It will be more efficient than the object destruction that is needed from the string.

提交回复
热议问题