From 64c96450a43c8c8c29bcd631c77de086966157dc Mon Sep 17 00:00:00 2001 From: ErrorNoInternet Date: Mon, 28 Apr 2025 20:49:14 -0400 Subject: [PATCH] perf(commands): move ncr data to binding --- src/commands.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 8990542..965b63a 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -19,14 +19,17 @@ pub struct CommandSource { impl CommandSource { pub fn reply(&self, message: &str) { + let ncr_data = self + .ncr_options + .as_ref() + .zip(self.state.lua.globals().get::("ncr_encrypt").ok()); for mut chunk in message .chars() .collect::>() .chunks(if self.ncr_options.is_some() { 150 } else { 236 }) .map(|chars| chars.iter().collect::()) { - if let Some(options) = &self.ncr_options - && let Ok(encrypt) = self.state.lua.globals().get::("ncr_encrypt") + if let Some((options, ref encrypt)) = ncr_data && let Ok(ciphertext) = encrypt.call::((options, prepend_header(&chunk))) { chunk = ciphertext;