From bf569b70dcd22bbad59d608bcb04c9f2846f8223 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 26 Oct 2018 11:24:43 -0700 Subject: [PATCH] Make cranelift-wasm's `type_to_type` easier to optimize. --- lib/wasm/src/translation_utils.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/wasm/src/translation_utils.rs b/lib/wasm/src/translation_utils.rs index d76d55494f..cc2926dad1 100644 --- a/lib/wasm/src/translation_utils.rs +++ b/lib/wasm/src/translation_utils.rs @@ -92,13 +92,13 @@ pub struct Memory { /// Helper function translating wasmparser types to Cranelift types when possible. pub fn type_to_type(ty: wasmparser::Type) -> Result { - match ty { - wasmparser::Type::I32 => Ok(ir::types::I32), - wasmparser::Type::I64 => Ok(ir::types::I64), - wasmparser::Type::F32 => Ok(ir::types::F32), - wasmparser::Type::F64 => Ok(ir::types::F64), - _ => Err(()), - } + Ok(match ty { + wasmparser::Type::I32 => ir::types::I32, + wasmparser::Type::I64 => ir::types::I64, + wasmparser::Type::F32 => ir::types::F32, + wasmparser::Type::F64 => ir::types::F64, + _ => return Err(()), + }) } /// Turns a `wasmparser` `f32` into a `Cranelift` one.