···761761 // UTF-8 conversion can be expensive, so we're going to do some safe naive
762762 // checks where we assume an upper-bound of the UTF-16 to UTF-8 conversion
763763764764- const maybeUtf8Len = input.length * 3;
764764+ const utf16Len = input.length;
765765+ const maybeUtf8Len = utf16Len * 3;
765766766766- // fail early if we're still less than minimum length
767767+ // fail early if estimated upper bound is too small
767768 if (maybeUtf8Len < minLength) {
768769 return issue;
769770 }
770771771771- // skip if we're still within maximum length
772772- if (maybeUtf8Len <= maxLength) {
772772+ // skip calculation if UTF-16 length already satisfies both constraints
773773+ if (utf16Len >= minLength && maybeUtf8Len <= maxLength) {
773774 return undefined;
774775 }
775776···822823823824 const utf16Len = input.length;
824825825825- // fail early if UTF-16 length is less than grapheme length
826826+ // fail early if UTF-16 length is too small
826827 if (utf16Len < minGraphemes) {
827828 return issue;
828829 }
829830830830- // skip if we're still within maximum constraint
831831- if (utf16Len <= maxGraphemes) {
831831+ // if there is no minimum bounds, we can safely skip when UTF-16 is
832832+ // within the maximum bounds.
833833+ if (minGraphemes === 0 && utf16Len <= maxGraphemes) {
832834 return undefined;
833835 }
834836