Skip to content

⚡ Bolt: 문자열 병합 최적화 (O(N^2) -> O(N)) - #38

Closed
seonghobae wants to merge 5 commits into
masterfrom
bolt/optimize-string-concat-13820306230969905600
Closed

⚡ Bolt: 문자열 병합 최적화 (O(N^2) -> O(N))#38
seonghobae wants to merge 5 commits into
masterfrom
bolt/optimize-string-concat-13820306230969905600

Conversation

@seonghobae

Copy link
Copy Markdown
Collaborator

💡 무엇을: index_middle 함수 내부에서 디렉토리 파일들을 반복문으로 돌며 HTML 문자열을 병합할 때, + 연산자 대신 StringBuilder를 사용하도록 최적화했습니다. 테스트 커버리지는 JaCoCo 플러그인을 추가하고 테스트 케이스를 강화하여 100%를 달성했습니다.
🎯 왜: Kotlin에서 반복문 내 문자열 병합(l += ...)은 문자열의 불변성 때문에 매 반복마다 새로운 문자열 객체를 할당하여 O(N^2)의 성능 저하를 일으키기 때문입니다.
📊 영향력: 파일이 많은 디렉토리에서 index.html을 생성할 때 반복적인 메모리 재할당과 가비지 컬렉션(GC) 압박을 크게 줄여 성능이 대폭 향상됩니다 (성능복잡도가 O(N^2)에서 O(N)으로 개선됨).
🔬 측정 방법: 파일이 많은 디렉토리를 대상으로 ./gradlew run --args="large_dir"를 실행해보면 최적화 전후의 생성 속도 차이를 확인할 수 있으며, 기존 로직이 정상 작동함은 ./gradlew test jacocoTestReport를 통해 100% 테스트 커버리지로 검증했습니다.


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

@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 June 27, 2026 21:08

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 improves html4tree’s directory index generation performance by optimizing HTML list-item string construction inside process_dir, and adds automated testing/coverage tooling to validate behavior and report coverage.

Changes:

  • Replaced per-iteration string concatenation in index_middle with StringBuilder-based accumulation.
  • Added a new Kotlin/JUnit test suite to cover CLI, directory processing, and utility behavior.
  • Enabled JaCoCo reporting in the Gradle build and documented the performance lesson in .jules/bolt.md.

Reviewed changes

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

File Description
src/main/kotlin/html4tree/main.kt Switches HTML concatenation logic in index_middle to a StringBuilder approach.
src/test/kotlin/html4tree/Html4treeTest.kt Adds tests covering CLI entrypoints and directory/index generation behaviors.
build.gradle Applies JaCoCo plugin and configures the jacocoTestReport reports.
.jules/bolt.md Documents the “String concatenation in loops” performance learning/action.

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

Comment thread src/main/kotlin/html4tree/main.kt Outdated
Comment thread src/test/kotlin/html4tree/Html4treeTest.kt
Comment thread src/test/kotlin/html4tree/Html4treeTest.kt
Comment thread src/test/kotlin/html4tree/Html4treeTest.kt
@seonghobae

Copy link
Copy Markdown
Collaborator Author

@copilot resolve the merge conflicts in this pull request

Copilot AI commented Jun 28, 2026

Copy link
Copy Markdown

@copilot resolve the merge conflicts in this pull request

Resolved and pushed in commit c52452d. The branch now includes the latest base changes with conflicts fixed in src/main/kotlin/html4tree/main.kt, and tests are passing.

@seonghobae

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by already-merged StringBuilder optimization (#21). Current master already uses StringBuilder for directory listing rendering; this branch is stale and would reintroduce older generator/test assumptions if merged directly.

@seonghobae seonghobae closed this Jun 30, 2026
@google-labs-jules

Copy link
Copy Markdown

Closing as superseded by already-merged StringBuilder optimization (#21). Current master already uses StringBuilder for directory listing rendering; this branch is stale and would reintroduce older generator/test assumptions if merged directly.

Understood. Acknowledging that this work is now obsolete and stopping work on this task.

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.

3 participants