Skip to content

Commit

Permalink
Auto merge of #16290 - Veykril:chalk, r=Veykril
Browse files Browse the repository at this point in the history
internal: Reduce vec cloning in mir lowering/eval
  • Loading branch information
bors committed Jan 6, 2024
2 parents e9ae0b7 + 5ac0c14 commit f595e60
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 257 deletions.
8 changes: 4 additions & 4 deletions crates/hir-ty/src/consteval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,15 @@ pub fn intern_const_ref(
LiteralConstRef::Int(i) => {
// FIXME: We should handle failure of layout better.
let size = layout.map(|it| it.size.bytes_usize()).unwrap_or(16);
ConstScalar::Bytes(i.to_le_bytes()[0..size].to_vec(), MemoryMap::default())
ConstScalar::Bytes(i.to_le_bytes()[0..size].into(), MemoryMap::default())
}
LiteralConstRef::UInt(i) => {
let size = layout.map(|it| it.size.bytes_usize()).unwrap_or(16);
ConstScalar::Bytes(i.to_le_bytes()[0..size].to_vec(), MemoryMap::default())
ConstScalar::Bytes(i.to_le_bytes()[0..size].into(), MemoryMap::default())
}
LiteralConstRef::Bool(b) => ConstScalar::Bytes(vec![*b as u8], MemoryMap::default()),
LiteralConstRef::Bool(b) => ConstScalar::Bytes(Box::new([*b as u8]), MemoryMap::default()),
LiteralConstRef::Char(c) => {
ConstScalar::Bytes((*c as u32).to_le_bytes().to_vec(), MemoryMap::default())
ConstScalar::Bytes((*c as u32).to_le_bytes().into(), MemoryMap::default())
}
LiteralConstRef::Unknown => ConstScalar::Unknown,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ fn render_const_scalar(
TyKind::Dyn(_) => {
let addr = usize::from_le_bytes(b[0..b.len() / 2].try_into().unwrap());
let ty_id = usize::from_le_bytes(b[b.len() / 2..].try_into().unwrap());
let Ok(t) = memory_map.vtable.ty(ty_id) else {
let Ok(t) = memory_map.vtable_ty(ty_id) else {
return f.write_str("<ty-missing-in-vtable-map>");
};
let Ok(layout) = f.db.layout_of_ty(t.clone(), trait_env) else {
Expand Down
4 changes: 2 additions & 2 deletions crates/hir-ty/src/infer/closure.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Inference of closure parameter types based on the closure's expected type.

use std::{cmp, collections::HashMap, convert::Infallible, mem};
use std::{cmp, convert::Infallible, mem};

use chalk_ir::{
cast::Cast,
Expand Down Expand Up @@ -778,7 +778,7 @@ impl InferenceContext<'_> {

fn minimize_captures(&mut self) {
self.current_captures.sort_by_key(|it| it.place.projections.len());
let mut hash_map = HashMap::<HirPlace, usize>::new();
let mut hash_map = FxHashMap::<HirPlace, usize>::default();
let result = mem::take(&mut self.current_captures);
for item in result {
let mut lookup_place = HirPlace { local: item.place.local, projections: vec![] };
Expand Down
Loading

0 comments on commit f595e60

Please sign in to comment.