Skip to content

Commit 1d232bb

Browse files
committed
Take advantage of the immutability of the state in the message parser to simplifiy the logic
1 parent 4f19842 commit 1d232bb

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

packages/errors/src/message-formatter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,14 @@ export function getHumanReadableErrorMessage<TErrorCode extends SolanaErrorCode>
6363
if (char === '\\') {
6464
nextState = { [START_INDEX]: ii, [TYPE]: StateType.EscapeSequence };
6565
} else if (char === '$') {
66-
commitStateUpTo(ii);
6766
nextState = { [START_INDEX]: ii, [TYPE]: StateType.Variable };
6867
} else if (!char.match(/\w/)) {
6968
nextState = { [START_INDEX]: ii, [TYPE]: StateType.Text };
7069
}
7170
break;
7271
}
7372
if (nextState) {
74-
if (state[TYPE] !== nextState[TYPE]) {
73+
if (state !== nextState) {
7574
commitStateUpTo(ii);
7675
}
7776
state = nextState;

0 commit comments

Comments
 (0)