Skip to content

Commit 2430870

Browse files
committed
Make SortedMap::new const, also faster is_empty.
1 parent d99a320 commit 2430870

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/librustc_data_structures/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#![feature(allow_internal_unstable)]
3131
#![feature(vec_resize_with)]
3232
#![feature(hash_raw_entry)]
33+
#![feature(const_fn)]
34+
#![feature(const_vec_new)]
3335

3436
#![cfg_attr(unix, feature(libc))]
3537
#![cfg_attr(test, feature(test))]

src/librustc_data_structures/sorted_map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ pub struct SortedMap<K: Ord, V> {
3030

3131
impl<K: Ord, V> SortedMap<K, V> {
3232
#[inline]
33-
pub fn new() -> SortedMap<K, V> {
33+
pub const fn new() -> SortedMap<K, V> {
3434
SortedMap {
35-
data: vec![]
35+
data: Vec::new()
3636
}
3737
}
3838

@@ -144,7 +144,7 @@ impl<K: Ord, V> SortedMap<K, V> {
144144

145145
#[inline]
146146
pub fn is_empty(&self) -> bool {
147-
self.len() == 0
147+
self.data.is_empty()
148148
}
149149

150150
#[inline]

0 commit comments

Comments
 (0)