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


##########
src/java/org/apache/cassandra/utils/ByteBufferUtil.java:
##########
@@ -726,6 +726,53 @@ public static int getShortLength(ByteBuffer bb, int 
position)
         return getUnsignedShort(bb, position);
     }
 
+    /**
+     * 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(ByteBuffer b, int off, long register, int 
bytes)
+    {
+        switch (bytes)
+        {
+            case 0:
+                break;
+            case 1:
+                b.put(off, (byte)(register >>> 56));
+                break;
+            case 2:
+                b.putShort(off, (short)(register >> 48));
+                break;
+            case 3:
+                b.putShort(off, (short)(register >> 48));
+                b.put(off + 2, (byte)(register >> 40));
+                break;
+            case 4:
+                b.putInt(off, (int)(register >> 32));
+                break;
+            case 5:
+                b.putInt(off, (int)(register >> 32));
+                b.put(off + 4, (byte)(register >> 24));
+                break;
+            case 6:
+                b.putInt(off, (int)(register >> 32));
+                b.putShort(off + 4, (short)(register >> 16));
+                break;
+            case 7:
+                b.putInt(off, (int)(register >> 32));
+                b.putShort(off + 4, (short)(register >> 16));

Review Comment:
   This should have been removed entirely, my mistake.



-- 
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