Skip to content

Commit 82e9b39

Browse files
authored
refactor: avoid calling dealStringToArr inside loop (#216)
1 parent d9c315a commit 82e9b39

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/helper/advanced.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,13 @@ export async function doFindComments() {
238238
const commentAuth = core.getInput('comment-auth');
239239
const bodyIncludes = core.getInput('body-includes');
240240
const direction = core.getInput('direction') === 'desc' ? 'desc' : 'asc';
241+
const bodyIncludesArr = dealStringToArr(bodyIncludes);
241242
for (const comment of commentList) {
242243
const checkUser = commentAuth ? comment.user.login === commentAuth : true;
243-
const checkBody = bodyIncludes
244-
? dealStringToArr(bodyIncludes).some(text => comment.body.includes(text))
245-
: true;
244+
const checkBody =
245+
bodyIncludesArr.length > 0
246+
? bodyIncludesArr.some(text => comment.body.includes(text))
247+
: true;
246248
if (checkUser && checkBody) {
247249
comments.push({
248250
id: comment.id,

0 commit comments

Comments
 (0)