Skip to content

Commit ce93ce5

Browse files
committed
Update
* Added feature gate required by box syntax. * `int`/`uint` types are getting deprecated, replaced some occurrences and added feature gate. * Adapted the usage of `XXHasher` to redesigned hashing.
1 parent 302103e commit ce93ce5

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#![crate_name="string_cache_macros"]
1111
#![crate_type="dylib"]
1212

13-
#![feature(plugin_registrar, quote)]
13+
#![feature(plugin_registrar, quote, int_uint, box_syntax)]
1414
#![allow(unused_imports)] // for quotes
1515

1616
extern crate core;

shared/repr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub const DYNAMIC_TAG: u8 = 0u8;
2626
pub const INLINE_TAG: u8 = 1u8; // len in upper nybble
2727
pub const STATIC_TAG: u8 = 2u8;
2828

29-
pub const MAX_INLINE_LEN: uint = 7;
29+
pub const MAX_INLINE_LEN: usize = 7;
3030

3131
// Atoms use a compact representation which fits this enum in a single u64.
3232
// Inlining avoids actually constructing the unpacked representation in memory.
@@ -41,7 +41,7 @@ pub enum UnpackedAtom {
4141
Static(u32),
4242
}
4343

44-
const STATIC_SHIFT_BITS: uint = 32;
44+
const STATIC_SHIFT_BITS: usize = 32;
4545

4646
#[inline(always)]
4747
unsafe fn inline_atom_slice(x: &u64) -> raw::Slice<u8> {
@@ -69,7 +69,7 @@ impl UnpackedAtom {
6969
n
7070
}
7171
Inline(len, buf) => {
72-
debug_assert!((len as uint) <= MAX_INLINE_LEN);
72+
debug_assert!((len as usize) <= MAX_INLINE_LEN);
7373
let mut data: u64 = (INLINE_TAG as u64) | ((len as u64) << 4);
7474
{
7575
let dest: &mut [u8] = mem::transmute(inline_atom_slice(&mut data));
@@ -89,7 +89,7 @@ impl UnpackedAtom {
8989
DYNAMIC_TAG => Dynamic(data as *mut ()),
9090
STATIC_TAG => Static((data >> STATIC_SHIFT_BITS) as u32),
9191
INLINE_TAG => {
92-
let len = ((data & 0xf0) >> 4) as uint;
92+
let len = ((data & 0xf0) >> 4) as usize;
9393
debug_assert!(len <= MAX_INLINE_LEN);
9494
let mut buf: [u8; 7] = [0; 7];
9595
let src: &[u8] = mem::transmute(inline_atom_slice(&data));

src/atom/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use core::prelude::*;
1313

1414
use phf::OrderedSet;
15-
use xxhash::XXHasher;
15+
use xxhash;
1616

1717
use core::fmt;
1818
use core::iter::RandomAccessIterator;
@@ -47,7 +47,6 @@ const ENTRY_ALIGNMENT: uint = 16;
4747
static static_atom_set: OrderedSet<&'static str> = static_atom_set!();
4848

4949
struct StringCache {
50-
hasher: XXHasher,
5150
buckets: [*mut StringCacheEntry; 4096],
5251
}
5352

@@ -78,13 +77,12 @@ impl StringCacheEntry {
7877
impl StringCache {
7978
fn new() -> StringCache {
8079
StringCache {
81-
hasher: XXHasher::new(),
8280
buckets: unsafe { mem::zeroed() },
8381
}
8482
}
8583

8684
fn add(&mut self, string_to_add: &str) -> *mut StringCacheEntry {
87-
let hash = self.hasher.hash(&string_to_add);
85+
let hash = xxhash::hash(&string_to_add);
8886
let bucket_index = (hash & (self.buckets.len()-1) as u64) as uint;
8987
let mut ptr = self.buckets[bucket_index];
9088

0 commit comments

Comments
 (0)