Skip to content

⚡ Bolt: [성능 개선] process_dir 내의 불변 상수 호이스팅#249

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

⚡ Bolt: [성능 개선] process_dir 내의 불변 상수 호이스팅#249
seonghobae wants to merge 1 commit into
masterfrom
bolt/hoist-constants-5081483986542290953

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

💡 What: process_dir 함수 내에서 매번 계산되던 불변 상수(cssContent, styleHash, css)를 최상위 private val로 호이스팅했습니다.
🎯 Why: 자주 호출되는 함수 내부에서 무거운 SHA-256 연산과 문자열 연결을 반복하면 불필요한 성능 저하와 가비지 컬렉션(GC) 압박이 발생합니다.
📊 Impact: 디렉토리 처리 속도 향상 및 메모리 할당 횟수 대폭 감소를 기대합니다.
🔬 Measurement: 단위 테스트를 실행하여 정상 작동 및 100% 테스트 커버리지 유지 여부를 확인합니다.


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

`process_dir` 함수 내에서 매번 재계산되던 불변 상수(`cssContent`, `styleHash`, `css`)를 클래스/파일 최상위 `private val`로 호이스팅했습니다.
이를 통해 디렉토리 크롤링 시 각 디렉토리마다 SHA-256 해시를 다시 계산하고 거대한 문자열을 할당하던 오버헤드가 제거되어 성능이 향상되고 GC 압박이 줄어듭니다.
@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 review requested due to automatic review settings July 23, 2026 03:33

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

This PR optimizes the html4tree Kotlin CLI’s HTML generation by hoisting per-directory, invariant CSS-related values out of the hot-path process_dir function so they are computed once at startup rather than on every directory render.

Changes:

  • Hoisted cssContent, styleHash (SHA-256), and css from inside process_dir to top-level private vals for reuse across calls.
  • Updated .jules/bolt.md with a new performance “learning/action” entry documenting the constant-hoisting optimization.

Reviewed changes

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

File Description
src/main/kotlin/html4tree/main.kt Hoists CSS/CSP hash computation out of process_dir to reduce repeated hashing and string allocations.
.jules/bolt.md Documents the performance rationale and action item for avoiding repeated expensive computations in hot paths.

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

Comment on lines +98 to +101
private val css = """
<style>
${cssContent} </style>
"""
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