From f276d85c9177423cee06d8d33a004aa1d4c2f1ca Mon Sep 17 00:00:00 2001 From: Michal Nazarewicz Date: Thu, 19 Oct 2023 21:09:15 +0200 Subject: [PATCH] solana-ibc: avoid unnecessary String allocation in Router impl (#39) --- solana/solana-ibc/programs/solana-ibc/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/solana/solana-ibc/programs/solana-ibc/src/lib.rs b/solana/solana-ibc/programs/solana-ibc/src/lib.rs index 8d5c611e..9ae5de0a 100644 --- a/solana/solana-ibc/programs/solana-ibc/src/lib.rs +++ b/solana/solana-ibc/programs/solana-ibc/src/lib.rs @@ -2,6 +2,7 @@ // not much we can do about it. #![allow(clippy::result_large_err)] +use core::borrow::Borrow; use std::collections::BTreeMap; use anchor_lang::prelude::*; @@ -418,7 +419,7 @@ pub trait SolanaIbcStorageHost { impl Router for SolanaIbcStorage<'_, '_> { // fn get_route(&self, module_id: &ModuleId) -> Option<&dyn Module> { - match module_id.to_string().as_str() { + match module_id.borrow() { ibc::applications::transfer::MODULE_ID_STR => { Some(&self.module_holder) } @@ -430,7 +431,7 @@ impl Router for SolanaIbcStorage<'_, '_> { &mut self, module_id: &ModuleId, ) -> Option<&mut dyn Module> { - match module_id.to_string().as_str() { + match module_id.borrow() { ibc::applications::transfer::MODULE_ID_STR => { Some(&mut self.module_holder) }