Last active
August 29, 2015 14:04
-
-
Save jzebedee/f5f13c68c022643cc11a to your computer and use it in GitHub Desktop.
WriteInt64 benchmark winners
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//winner x64 | |
private static void WriteInt64E(long y, byte[] buf, int offset) | |
{ | |
if (y < 0) | |
{ | |
y = -y; | |
buf[offset] = (byte)y; | |
buf[offset + 1] = (byte)(y >>= 8); | |
buf[offset + 2] = (byte)(y >>= 8); | |
buf[offset + 3] = (byte)(y >>= 8); | |
buf[offset + 4] = (byte)(y >>= 8); | |
buf[offset + 5] = (byte)(y >>= 8); | |
buf[offset + 6] = (byte)(y >>= 8); | |
buf[offset + 7] = (byte)((y >> 8) | 0x80); | |
} | |
else | |
{ | |
buf[offset] = (byte)y; | |
buf[offset + 1] = (byte)(y >>= 8); | |
buf[offset + 2] = (byte)(y >>= 8); | |
buf[offset + 3] = (byte)(y >>= 8); | |
buf[offset + 4] = (byte)(y >>= 8); | |
buf[offset + 5] = (byte)(y >>= 8); | |
buf[offset + 6] = (byte)(y >>= 8); | |
buf[offset + 7] = (byte)(y >> 8); | |
} | |
} | |
//winner x86 | |
private static void WriteInt64F(long value, byte[] buf, int offset) | |
{ | |
long y = value < 0 ? -value : value; | |
buf[offset] = (byte)y; | |
buf[offset + 1] = (byte)(y >>= 8); | |
buf[offset + 2] = (byte)(y >>= 8); | |
buf[offset + 3] = (byte)(y >>= 8); | |
buf[offset + 4] = (byte)(y >>= 8); | |
buf[offset + 5] = (byte)(y >>= 8); | |
buf[offset + 6] = (byte)(y >>= 8); | |
buf[offset + 7] = (byte)(y >>= 8); | |
if (value < 0) | |
buf[offset + 7] |= 0x80; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment