diff --git a/.jules/bolt.md b/.jules/bolt.md
index e79ba97..5ce9472 100644
--- a/.jules/bolt.md
+++ b/.jules/bolt.md
@@ -1,3 +1,6 @@
## 2024-05-17 - O(N) lookup optimizations for Discord.js
**Learning:** Found two O(N) operations in bot.js and module Tipper scripts when looking up members or guild count.
**Action:** Replaced `bot.guilds.array().length` with `bot.guilds.size` (O(1)) and `message.guild.members.find('id', recipient)` with `message.guild.members.get(recipient)` (O(1)).
+## 2024-05-17 - Optimize String Tokenization in Message Parsing
+**Learning:** Found string tokenization logic using chained `.trim().split(' ').filter(...)` which causes intermediate array allocations, reducing performance when parsing incoming messages frequently.
+**Action:** Replaced the chain with `.match(/\S+/g) || []` to perform whitespace tokenization directly via regular expression without creating intermediate array references.
diff --git a/bot/modules/dogeTipper.js b/bot/modules/dogeTipper.js
index 54258df..9f97c74 100644
--- a/bot/modules/dogeTipper.js
+++ b/bot/modules/dogeTipper.js
@@ -19,12 +19,9 @@ exports.tipdoge = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
- words = msg.content
- .trim()
- .split(' ')
- .filter(function (n) {
- return n !== '';
- }),
+ words =
+ msg.content.match(/\S+/g) ||
+ [] /* ⚡ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Dogecoin (DOGE) Tipper**__\nTransaction Fees: **' +
diff --git a/bot/modules/exampleTipper.js b/bot/modules/exampleTipper.js
index 25be559..d650ffd 100644
--- a/bot/modules/exampleTipper.js
+++ b/bot/modules/exampleTipper.js
@@ -29,11 +29,7 @@ exports.tipltc = {
process: async function(bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
words = msg.content
- .trim()
- .split(' ')
- .filter(function(n) {
- return n !== '';
- }),
+ .match(/\S+/g) || [], // ⚡ Bolt: Optimize message parsing by avoiding intermediate array allocations
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Litecoin (LTC) Tipper**__\nTransaction Fees: **' + paytxfee + '**\n **!tipltc** : Displays This Message\n **!tipltc balance** : get your balance\n **!tipltc deposit** : get address for your deposits\n **!tipltc withdraw
** : withdraw coins to specified address\n **!tipltc <@user> ** :mention a user with @ and then the amount to tip them\n **!tipltc private ** : put private before Mentioning a user to tip them privately.\n\n **<> : Replace with appropriate value.**',
diff --git a/bot/modules/ftcTipper.js b/bot/modules/ftcTipper.js
index 22bb0b9..23283e1 100644
--- a/bot/modules/ftcTipper.js
+++ b/bot/modules/ftcTipper.js
@@ -19,12 +19,9 @@ exports.tipftc = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
- words = msg.content
- .trim()
- .split(' ')
- .filter(function (n) {
- return n !== '';
- }),
+ words =
+ msg.content.match(/\S+/g) ||
+ [] /* ⚡ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Feathercoin (FTC) Tipper**__\nTransaction Fees: **' +
diff --git a/bot/modules/lbcTipper.js b/bot/modules/lbcTipper.js
index 09ff576..8d032ec 100644
--- a/bot/modules/lbcTipper.js
+++ b/bot/modules/lbcTipper.js
@@ -19,12 +19,9 @@ exports.tiplbc = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
- words = msg.content
- .trim()
- .split(' ')
- .filter(function (n) {
- return n !== '';
- }),
+ words =
+ msg.content.match(/\S+/g) ||
+ [] /* ⚡ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**LBRY Credit (LBC) Tipper**__\nTransaction Fees: **' +
diff --git a/bot/modules/protonTipper.js b/bot/modules/protonTipper.js
index 53da2cd..89750bc 100644
--- a/bot/modules/protonTipper.js
+++ b/bot/modules/protonTipper.js
@@ -19,12 +19,9 @@ exports.tipproton = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
- words = msg.content
- .trim()
- .split(' ')
- .filter(function (n) {
- return n !== '';
- }),
+ words =
+ msg.content.match(/\S+/g) ||
+ [] /* ⚡ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Proton (PROTON) Tipper**__\nTransaction Fees: **' +
diff --git a/bot/modules/pxcTipper.js b/bot/modules/pxcTipper.js
index db95dc4..19a789d 100644
--- a/bot/modules/pxcTipper.js
+++ b/bot/modules/pxcTipper.js
@@ -19,12 +19,9 @@ exports.tippxc = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
- words = msg.content
- .trim()
- .split(' ')
- .filter(function (n) {
- return n !== '';
- }),
+ words =
+ msg.content.match(/\S+/g) ||
+ [] /* ⚡ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Phoenixcoin (PXC) Tipper**__\nTransaction Fees: **' +
diff --git a/bot/modules/rvnTipper.js b/bot/modules/rvnTipper.js
index 814abc4..005f4a3 100644
--- a/bot/modules/rvnTipper.js
+++ b/bot/modules/rvnTipper.js
@@ -19,12 +19,9 @@ exports.tiprvn = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
- words = msg.content
- .trim()
- .split(' ')
- .filter(function (n) {
- return n !== '';
- }),
+ words =
+ msg.content.match(/\S+/g) ||
+ [] /* ⚡ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Ravencoin (RVN) Tipper**__\nTransaction Fees: **' +
diff --git a/bot/modules/ufoTipper.js b/bot/modules/ufoTipper.js
index 74c1cd5..6a62c30 100644
--- a/bot/modules/ufoTipper.js
+++ b/bot/modules/ufoTipper.js
@@ -19,12 +19,9 @@ exports.tipufo = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
- words = msg.content
- .trim()
- .split(' ')
- .filter(function (n) {
- return n !== '';
- }),
+ words =
+ msg.content.match(/\S+/g) ||
+ [] /* ⚡ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Uniform Fiscal Object (UFO) Tipper**__\nTransaction Fees: **' +
diff --git a/bot/modules/vtlTipper.js b/bot/modules/vtlTipper.js
index 040a3fa..0caa8dc 100644
--- a/bot/modules/vtlTipper.js
+++ b/bot/modules/vtlTipper.js
@@ -19,12 +19,9 @@ exports.tipvtl = {
paytxfee,
process: async function (bot, msg, suffix) {
let tipper = msg.author.id.replace('!', ''),
- words = msg.content
- .trim()
- .split(' ')
- .filter(function (n) {
- return n !== '';
- }),
+ words =
+ msg.content.match(/\S+/g) ||
+ [] /* ⚡ Bolt: Optimize message parsing by avoiding intermediate array allocations */,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Vertical (VTL) Tipper**__\nTransaction Fees: **' +