Skip to content

Commit 8061598

Browse files
committed
remove pstr_vec
1 parent 823b74c commit 8061598

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2459
-2138
lines changed

build/static_string_indexing.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const INLINED_ATOM_MAX_LEN: usize = 6;
8989
fn static_string_index(string: &str, index: usize) -> u64 {
9090
if 0 < string.len() && string.len() <= INLINED_ATOM_MAX_LEN {
9191
let mut string_buf: [u8; 8] = [0u8; 8];
92-
string_buf[.. string.len()].copy_from_slice(string.as_bytes());
92+
string_buf[..string.len()].copy_from_slice(string.as_bytes());
9393
(u64::from_le_bytes(string_buf) << 1) | 1
9494
} else {
9595
(index << 1) as u64
@@ -165,22 +165,26 @@ pub fn index_static_strings(instruction_rs_path: &std::path::Path) -> TokenStrea
165165
let mut static_strs = vec![];
166166
let mut static_str_indices = vec![];
167167

168-
let indices: Vec<u64> = visitor.static_strs.iter().map(|string| {
169-
let index = static_string_index(string, static_strs.len());
168+
let indices: Vec<u64> = visitor
169+
.static_strs
170+
.iter()
171+
.map(|string| {
172+
let index = static_string_index(string, static_strs.len());
170173

171-
static_str_keys.push(string);
174+
static_str_keys.push(string);
172175

173-
if index & 1 == 1 {
174-
index
175-
} else {
176-
static_str_indices.push(index);
177-
static_strs.push(string);
178-
index
179-
}
180-
}).collect();
176+
if index & 1 == 1 {
177+
index
178+
} else {
179+
static_str_indices.push(index);
180+
static_strs.push(string);
181+
index
182+
}
183+
})
184+
.collect();
181185

182186
let static_strs_len = static_strs.len(); // visitor.static_strs.len();
183-
//let static_strs: &Vec<_> = &visitor.static_strs.into_iter().collect();
187+
//let static_strs: &Vec<_> = &visitor.static_strs.into_iter().collect();
184188

185189
quote! {
186190
static STRINGS: [&str; #static_strs_len] = [

src/arithmetic.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,6 @@ impl Div<Number> for Number {
479479
}
480480
}
481481

482-
483482
impl PartialEq for Number {
484483
fn eq(&self, rhs: &Self) -> bool {
485484
match (self, rhs) {
@@ -563,7 +562,6 @@ impl PartialOrd for Number {
563562
}
564563
}
565564

566-
567565
impl Ord for Number {
568566
fn cmp(&self, rhs: &Number) -> Ordering {
569567
match (self, rhs) {

src/atom_table.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ impl AtomCell {
6666
debug_assert!(string.len() <= INLINED_ATOM_MAX_LEN);
6767

6868
let mut string_buf: [u8; 8] = [0u8; 8];
69-
string_buf[.. string.len()].copy_from_slice(string.as_bytes());
69+
string_buf[..string.len()].copy_from_slice(string.as_bytes());
7070
let encoding = u64::from_le_bytes(string_buf);
7171

7272
AtomCell::new()
@@ -80,7 +80,7 @@ impl AtomCell {
8080

8181
#[inline]
8282
pub fn new_char_inlined(c: char) -> Self {
83-
let mut char_buf = [0u8;8];
83+
let mut char_buf = [0u8; 8];
8484
c.encode_utf8(&mut char_buf);
8585

8686
let encoding = u64::from_le_bytes(char_buf);
@@ -109,7 +109,9 @@ impl AtomCell {
109109

110110
#[inline]
111111
pub fn get_name(self) -> Atom {
112-
Atom { index: (self.name() << 1) | self.is_inlined() as u64 }
112+
Atom {
113+
index: (self.name() << 1) | self.is_inlined() as u64,
114+
}
113115
}
114116

115117
#[inline]
@@ -216,21 +218,22 @@ impl Hash for Atom {
216218

217219
pub enum AtomString<'a> {
218220
Static(&'a str),
219-
Inlined([u8;8]),
221+
Inlined([u8; 8]),
220222
Dynamic(AtomTableRef<str>),
221223
}
222224

223-
fn inlined_to_str<'a>(bytes: &'a [u8;8]) -> &'a str {
225+
fn inlined_to_str<'a>(bytes: &'a [u8; 8]) -> &'a str {
224226
// allow the '\0\' atom to be represented as the 0-valued inlined atom
225227
let slice_len = if bytes[0] == 0 {
226228
1
227229
} else {
228-
bytes.iter().position(|&b| b == 0u8).unwrap_or(INLINED_ATOM_MAX_LEN)
230+
bytes
231+
.iter()
232+
.position(|&b| b == 0u8)
233+
.unwrap_or(INLINED_ATOM_MAX_LEN)
229234
};
230235

231-
unsafe {
232-
str::from_utf8_unchecked(&bytes[..slice_len])
233-
}
236+
unsafe { str::from_utf8_unchecked(&bytes[..slice_len]) }
234237
}
235238

236239
impl std::fmt::Debug for AtomString<'_> {

0 commit comments

Comments
 (0)