aweisberg commented on code in PR #1951:
URL: https://github.com/apache/cassandra/pull/1951#discussion_r1014476658


##########
src/java/org/apache/cassandra/utils/ByteArrayUtil.java:
##########
@@ -195,6 +195,53 @@ public static void putDouble(byte[] b, int off, double 
val) {
         putLong(b, off, Double.doubleToLongBits(val));
     }
 
+    /**
+     * An efficient way to write the type {@code bytes} of a long
+     *
+     * @param register - the long value to be written
+     * @param bytes - the number of bytes the register occupies. Valid values 
are between 1 and 8 inclusive.
+     * @throws IOException
+     */
+    public static void putBytes(byte[] b, int off, long register, int bytes)
+    {
+        switch (bytes)
+        {
+            case 0:
+                break;
+            case 1:
+                b[off] = (byte)(register >>> 56);
+                break;
+            case 2:
+                putShort(b, off, (short)(register >> 48));
+                break;
+            case 3:
+                putShort(b, off, (short)(register >> 48));
+                b[off + 2] = (byte)(register >> 40);
+                break;
+            case 4:
+                putInt(b, off, (int)(register >> 32));
+                break;
+            case 5:
+                putInt(b, off, (int)(register >> 32));
+                b[off + 4] = (byte)(register >> 24);
+                break;
+            case 6:
+                putInt(b, off, (int)(register >> 32));
+                putShort(b, off + 4, (short)(register >> 16));
+                break;
+            case 7:
+                putInt(b, off, (int)(register >> 32));
+                putShort(b, off + 4, (short)(register >> 16));

Review Comment:
   FYI still here 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to