Skip to content

Commit a667ec5

Browse files
committed
optimize uppercase()
1 parent baa3647 commit a667ec5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

string.gs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ func uppercase(text) {
7474
local i = 1;
7575
repeat length($text) {
7676
local j = 1;
77-
until $text[i] == ASCII_UPPERCASE[j] or j > 26 {
77+
# This also detects for empty string, which happens when j is out of range of ASCII_UPPERCASE, i.e j > 26
78+
until ASCII_UPPERCASE[j] in $text[i] {
7879
j++;
7980
}
8081
if j > 26 {

test/main.gs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ costumes "blank.svg";
44
%include inflator/string
55

66
onflag {
7-
# assert_eq
7+
assert_eq uppercase("test..?"), "TEST..?", "uppercase";
88
}

0 commit comments

Comments
 (0)