Skip to content

Commit

Permalink
Fix slowness with larger templates
Browse files Browse the repository at this point in the history
Closes #69 and #71
Released 3.0.5
  • Loading branch information
fidian committed Mar 28, 2024
1 parent 6e57510 commit 26ca505
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Please note that this command is written in Bash and pulls data from either the


Enhancements
-----------
------------

In addition to many of the features built-in to Mustache, `mo` includes a number of unique features that make it a bit more powerful.

Expand Down
28 changes: 19 additions & 9 deletions mo
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,29 @@ mo::indirectArray() {
#
# Returns nothing.
mo::trimUnparsed() {
local moLast moR moN moT
local moLastLen moR moN moT

moLast=""
moLastLen=0
moR=$'\r'
moN=$'\n'
moT=$'\t'

while [[ "$MO_UNPARSED" != "$moLast" ]]; do
moLast=$MO_UNPARSED
MO_UNPARSED=${MO_UNPARSED# }
MO_UNPARSED=${MO_UNPARSED#"$moR"}
MO_UNPARSED=${MO_UNPARSED#"$moN"}
MO_UNPARSED=${MO_UNPARSED#"$moT"}
while [[ "${#MO_UNPARSED}" != "$moLastLen" ]]; do
moLastLen=${#MO_UNPARSED}

# These conditions are necessary for a significant speed increase
while [[ "${MO_UNPARSED:0:1}" == " " ]]; do
MO_UNPARSED=${MO_UNPARSED# }
done
while [[ "${MO_UNPARSED:0:1}" == "$moR" ]]; do
MO_UNPARSED=${MO_UNPARSED#"$moR"}
done
while [[ "${MO_UNPARSED:0:1}" == "$moN" ]]; do
MO_UNPARSED=${MO_UNPARSED#"$moN"}
done
while [[ "${MO_UNPARSED:0:1}" == "$moT" ]]; do
MO_UNPARSED=${MO_UNPARSED#"$moT"}
done
done
}

Expand Down Expand Up @@ -1950,7 +1960,7 @@ mo::tokenizeTagContentsSingleQuote() {

# Save the original command's path for usage later
MO_ORIGINAL_COMMAND="$(cd "${BASH_SOURCE[0]%/*}" || exit 1; pwd)/${BASH_SOURCE[0]##*/}"
MO_VERSION="3.0.4"
MO_VERSION="3.0.5"

# If sourced, load all functions.
# If executed, perform the actions as expected.
Expand Down
2 changes: 1 addition & 1 deletion tests/help
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ This is open source! Please feel free to contribute.
https://github.com/tests-always-included/mo
MO_VERSION=3.0.4
MO_VERSION=3.0.5
EOF
}

Expand Down

0 comments on commit 26ca505

Please sign in to comment.