提交 f9562a5c 编写于 作者: L liunian

remove unnecessary calculation

上级 c83fa467
......@@ -164,7 +164,7 @@ export function startsWith(haystack: string, needle: string): boolean {
export function endsWith(haystack: string, needle: string): boolean {
let diff = haystack.length - needle.length;
if (diff > 0) {
return haystack.lastIndexOf(needle) === haystack.length - needle.length;
return haystack.lastIndexOf(needle) === diff;
} else if (diff === 0) {
return haystack === needle;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册