Created
April 16, 2015 16:51
-
-
Save soc/d2adf0f48e036507df58 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** Returns the size and the remaining vector. */ | |
def segmentBodySize(vector: ByteVector): (Int, ByteVector) = { | |
def loop(index: Int = 0, accum: Int = 0): (Int, ByteVector) = { | |
val value = (vector(index) & 0xFF) | |
if (value != 255) { | |
(value + accum, vector.drop(index + 1)) | |
} else { | |
loop(value + accum, index + 1) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment