From 763512bbe83b4c6d9dc900f390826320cf865efa Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Sun, 5 Jul 2026 12:16:10 +0000
Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20[performance=20improvement]?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Optimized token extraction in message parsing across tipper modules using `.match(/\S+/g) || []` instead of chained array allocations (`.trim().split(' ').filter(...)`).
Co-authored-by: DerUntote <8378077+DerUntote@users.noreply.github.com>
---
.jules/bolt.md | 4 ++++
bot/modules/dogeTipper.js | 9 +++------
bot/modules/exampleTipper.js | 9 +++------
bot/modules/ftcTipper.js | 9 +++------
bot/modules/lbcTipper.js | 9 +++------
bot/modules/protonTipper.js | 9 +++------
bot/modules/pxcTipper.js | 9 +++------
bot/modules/rvnTipper.js | 9 +++------
bot/modules/ufoTipper.js | 9 +++------
bot/modules/vtlTipper.js | 9 +++------
10 files changed, 31 insertions(+), 54 deletions(-)
diff --git a/.jules/bolt.md b/.jules/bolt.md
index e79ba97..6960943 100644
--- a/.jules/bolt.md
+++ b/.jules/bolt.md
@@ -1,3 +1,7 @@
## 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-18 - Avoid unnecessary array allocations when parsing Discord messages
+**Learning:** The previous implementation used `.trim().split(' ').filter(...)` to extract tokens from message content, which allocates multiple intermediate arrays for every command invocation.
+**Action:** Replaced `.trim().split(' ').filter(...)` with `.match(/\S+/g) || []` to directly extract non-whitespace tokens, improving memory efficiency and performance.
diff --git a/bot/modules/dogeTipper.js b/bot/modules/dogeTipper.js
index 54258df..e2b8bda 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: Use Regex match instead of trim/split/filter to avoid 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..6606865 100644
--- a/bot/modules/exampleTipper.js
+++ b/bot/modules/exampleTipper.js
@@ -28,12 +28,9 @@ exports.tipltc = {
'__**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 has a default txfee of ' + 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: Use Regex match instead of trim/split/filter to avoid 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..5be1597 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: Use Regex match instead of trim/split/filter to avoid 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..913abce 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: Use Regex match instead of trim/split/filter to avoid 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..c2e1090 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: Use Regex match instead of trim/split/filter to avoid 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..7e15476 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: Use Regex match instead of trim/split/filter to avoid 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..2a9b9b6 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: Use Regex match instead of trim/split/filter to avoid 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..57ab474 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: Use Regex match instead of trim/split/filter to avoid 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..063972d 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: Use Regex match instead of trim/split/filter to avoid intermediate array allocations
+ ,
subcommand = words.length >= 2 ? words[1] : 'help',
helpmsg =
'__**Vertical (VTL) Tipper**__\nTransaction Fees: **' +