Skip to content

Commit e7df0a4

Browse files
committed
Simplify get() after contains()
1 parent 603d342 commit e7df0a4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/declare.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use crate::intrinsic::llvm;
1111
impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
1212
pub fn get_or_insert_global(&self, name: &str, ty: Type<'gcc>, is_tls: bool, link_section: Option<Symbol>) -> LValue<'gcc> {
1313
if self.globals.borrow().contains_key(name) {
14-
// TODO: use [] instead of .get().expect()?
15-
let typ = self.globals.borrow().get(name).expect("global").get_type();
14+
let typ = self.globals.borrow()[name].get_type();
1615
let global = self.context.new_global(None, GlobalKind::Imported, typ, name);
1716
if is_tls {
1817
global.set_tls_model(self.tls_model);
@@ -110,7 +109,7 @@ fn declare_raw_fn<'gcc>(cx: &CodegenCx<'gcc, '_>, name: &str, _callconv: () /*ll
110109
}
111110
let func =
112111
if cx.functions.borrow().contains_key(name) {
113-
*cx.functions.borrow().get(name).expect("function")
112+
cx.functions.borrow()[name]
114113
}
115114
else {
116115
let params: Vec<_> = param_types.into_iter().enumerate()

0 commit comments

Comments
 (0)