From 7109e30dcb5a60bc3db3f5e834649fa52f05761c Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Mon, 3 Jul 2017 01:44:11 -0400 Subject: [PATCH] Use ByteOrder function in decode_uint --- src/ebml.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ebml.rs b/src/ebml.rs index d3749a5..022463c 100644 --- a/src/ebml.rs +++ b/src/ebml.rs @@ -1,3 +1,5 @@ +use byteorder::{BigEndian, ByteOrder}; + pub const EBML_HEAD_ID: u64 = 0x0A45DFA3; pub const VOID_ID: u64 = 0x6C; @@ -98,9 +100,7 @@ pub fn decode_uint(bytes: &[u8]) -> Result { return Err(Error::CorruptPayload); } - let mut value: u64 = 0; - for byte in bytes { - value = (value << 8) + (*byte as u64); + Ok(BigEndian::read_uint(bytes, bytes.len())) } Ok(value) }