engine: Centralized leafnode-related code in one place#1001
Merged
Conversation
ytaek
approved these changes
Oct 14, 2025
Contributor
ytaek
left a comment
There was a problem hiding this comment.
오! 멋진 리팩토링입니다!!!
Test 까지 너무 좋네용!
nxnaxx
approved these changes
Oct 15, 2025
Contributor
nxnaxx
left a comment
There was a problem hiding this comment.
LGTM!! 테스트 코드까지 꼼꼼하게 고생하셨습니다👍🏻
|
|
||
| export const isLeafNode = (node: CommitNode): boolean => node.commit.branches.length > 0; | ||
|
|
||
| export const latestFirstComparator = (a: CommitNode, b: CommitNode): number => { |
| const leafNodes: CommitNode[] = []; | ||
| commitDict.forEach((node) => node.commit.branches.length && leafNodes.push(node)); | ||
| return leafNodes; | ||
| return [...commitDict.values()].filter(isLeafNode); |
Contributor
There was a problem hiding this comment.
isLeafNode까지 재사용해서 훨씬 깔끔해졌네요ㅎㅎ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
#1000
Result
Queue constructor를 봤을 때 어떤 기준으로 sort하는지 알 수 있고(
latestFirstComparator) comparator 함수를 봤을 때commit.branches.length가 아닌isLeafNode라는 이름을 사용함으로써commit.branches.length가 어떤 케이스인지이해하기 쉽다.
Work list
Discussion