Skip to content

Commit 1c3c010

Browse files
committed
libextra: Use from_be32 instead of bswap32 in vuint_at()
Also use the fast version of vuint_at() on all architectures since it now works on both big and little endian architectures.
1 parent 19d8ab8 commit 1c3c010

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/libextra/ebml.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,9 @@ pub mod reader {
122122
fail!("vint too big");
123123
}
124124

125-
#[cfg(target_arch = "x86")]
126-
#[cfg(target_arch = "x86_64")]
127125
pub fn vuint_at(data: &[u8], start: uint) -> Res {
128126
use std::ptr::offset;
129-
use std::unstable::intrinsics::bswap32;
127+
use std::unstable::intrinsics::from_be32;
130128

131129
if data.len() - start < 4 {
132130
return vuint_at_slow(data, start);
@@ -136,7 +134,7 @@ pub mod reader {
136134
let (ptr, _): (*u8, uint) = transmute(data);
137135
let ptr = offset(ptr, start as int);
138136
let ptr: *i32 = transmute(ptr);
139-
let val = bswap32(*ptr);
137+
let val = from_be32(*ptr);
140138
let val: u32 = transmute(val);
141139
if (val & 0x80000000) != 0 {
142140
Res {
@@ -162,11 +160,6 @@ pub mod reader {
162160
}
163161
}
164162

165-
#[cfg(not(target_arch = "x86"), not(target_arch = "x86_64"))]
166-
pub fn vuint_at(data: &[u8], start: uint) -> Res {
167-
vuint_at_slow(data, start)
168-
}
169-
170163
pub fn Doc<'a>(data: &'a [u8]) -> Doc<'a> {
171164
Doc { data: data, start: 0u, end: data.len() }
172165
}

0 commit comments

Comments
 (0)