Skip to content

⚡ Bolt: [성능 개선] 불변 문자열 및 해시 연산 함수 외부로 추출#240

Open
seonghobae wants to merge 1 commit into
masterfrom
bolt-hoist-constants-17408967309212707276
Open

⚡ Bolt: [성능 개선] 불변 문자열 및 해시 연산 함수 외부로 추출#240
seonghobae wants to merge 1 commit into
masterfrom
bolt-hoist-constants-17408967309212707276

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

💡 What: process_dir 함수 내에서 매번 생성되던 불변 문자열 (cssContent, css)과 비싼 SHA-256 해시 연산(styleHash)을 파일 최상단 private val 상수로 추출했습니다.
🎯 Why: process_dir는 디렉토리를 탐색하며 반복 호출되는데, 내부에서 불변 문자열을 할당하고 해시 연산을 수행하면 불필요한 메모리 할당과 CPU 자원 낭비(성능 저하)가 발생합니다.
📊 Impact: 불필요한 인스턴스 생성 및 SHA-256 해시 연산을 클래스 로드 시 1회로 줄여 디렉토리 크롤링 속도를 최적화했습니다. (Jacoco 커버리지 100% 유지)
🔬 Measurement: ./gradlew clean test jacocoTestReport jacocoTestCoverageVerification 실행을 통해 모든 테스트가 통과하고 100% 코드 커버리지를 유지하는지 확인했습니다.


PR created automatically by Jules for task 17408967309212707276 started by @seonghobae

Copilot AI review requested due to automatic review settings July 22, 2026 03:33
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

process_dir가 반복 호출될 때마다 재생성되던 CSS 문자열과 SHA-256 해시 계산을 파일 최상단으로 이동해 중복 연산/할당을 줄여 성능을 개선합니다.

Changes:

  • process_dir 내부의 CSS 문자열(cssContent, css)을 파일 레벨 private val로 추출
  • CSS에 대한 SHA-256 해시(styleHash) 계산을 파일 레벨 private val로 추출
  • 성능 최적화 학습/조치 내용을 .jules/bolt.md에 기록

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/main/kotlin/html4tree/main.kt 반복 호출 경로에서 불변 문자열/해시 연산을 제거하기 위해 전역 private val로 승격
.jules/bolt.md 이번 성능 최적화에 대한 학습/액션 로그 추가

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +309 to 314
private val styleHash = "sha256-" + Base64.getEncoder().encodeToString(MessageDigest.getInstance("SHA-256").digest(cssContent.toByteArray(Charsets.UTF_8)))

val css = """
private val css = """
<style>
${cssContent} </style>
"""
Comment thread .jules/bolt.md
Comment on lines +46 to +48
## 2026-07-22 - 불변 문자열 및 해시 연산 외부 추출에 따른 성능 최적화
**Learning:** 반복 호출되는 함수 내에서 SHA-256과 같은 비싼 연산 및 긴 문자열을 할당하면 불필요한 성능 저하가 발생합니다. Kotlin에서 이를 파일 최상단 상수로 승격시키되, `private val`로 선언해야 Jacoco 커버리지가 떨어지는 것을 방지할 수 있습니다.
**Action:** 반복 호출되는 함수의 변하지 않는 값과 비싼 연산은 파일 최상단 `private val` 상수로 추출하여 성능을 최적화합니다.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants