Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
1 task done
This branch had an error being deployed
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.
Overview
역방향 조회용 객체를 만드는 로직이 각 함수에 흩어져 있고, 일부는 호출·순회마다 역방향 객체를 새로 생성하는 비효율인 부분이 있었습니다.
공통
invert유틸을 추가해 역방향 객체 생성을 일원화하고,combineVowels와getJongseong이 이를 사용하도록 리팩터링했습니다.문제 상황 (as-is)
1.
combineVowels— 호출마다 O(n) 선형 탐색Object.entries(...).find(...)로 역방향 탐색을 선형(O(n))으로 수행합니다.2.
getJongseong— 역방향 객체를 매 순회마다 재생성Object.fromEntries(...)로 만드는 역방향 객체가.map콜백이 실행될 때마다 매번 새로 생성됩니다.JONGSEONGS.slice(1)의 길이만큼 동일한 객체를 반복 생성합니다. → 사실상O(n²)변경 사항 (to-be)
1. 공통
invert유틸 추가 (src/_internal)공통
invert유틸을 추가해 역방향 객체 생성을 일원화하고,combineVowels와getJongseong이 이를 사용하도록 리팩터링했습니다.2.
combineVowels적용호출마다
entries를 생성하고,find로 탐색하던 로직을, 모듈 스코프에서invert로 1회 생성한 역방향 객체를 통해 조회(O(1))하도록 변경했습니다.3.
getJongseong적용동일하게 역방향 객체를 모듈 스코프에서 한 번만 생성하도록 분리합니다.
개선 포인트
invert유틸로 일원화 (중복 제거, 재사용성 확보)combineVowels: 호출마다entries생성 후find탐색 → 모듈 스코프에서 역방향 객체 생성 후O(1)객체 조회로 개선getJongseong: JONGSEONGS.slice(1)`의 길이만큼(약 27회) 동일한 객체를 반복 생성하는 것을 사전 생성 후 조회로 개선영향도
combineVowels,getJongseong의 동작은 동일하며, 기존 테스트는 모두 통과합니다.PR Checklist