79638160

Date: 2025-05-26 00:16:09
Score: 0.5
Natty:
Report link

Why all these unneeded multiplications, divisions and shifts? You are loosing precious resources.

I don't know if there is big or little endian, so here are both.

//assume bytes_to_write is original (x2), not modified to 24 (x3)

//Big endian
for (int i = 0, j=0; i < bytes_to_write; i+=2, j+=3) {
  current_pos_16[j]   = current_pos[i];
  current_pos_16[j+1] = current_pos[i+1];
  current_pos_16[j+2] = 0;
}

//Little endian
for (int i = 0, j=0; i < bytes_to_write; i+=2, j+=3) {
  current_pos_16[j]   = 0;
  current_pos_16[j+1] = current_pos[i];
  current_pos_16[j+2] = current_pos[i+1];
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Starts with a question (0.5): Why
  • Low reputation (0.5):
Posted by: Solt