Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@
## 2026-08-09 - 반복 호출되는 함수 내 정적 리스트 최적화
**Learning:** 디렉토리를 탐색할 때마다 호출되는 함수(process_ignore_file) 내부에서 listOf()로 고정된 리스트를 할당하면 불필요한 메모리 할당과 GC 부하가 발생합니다.
**Action:** 정적인 컬렉션은 private object로 추출하고 @JvmField 등을 활용하여 단 한 번만 초기화되도록 최적화해야 합니다.

## 2026-08-11 - Comparator 객체 재사용
**학습:** 반복 호출되는 디렉터리 정렬 경계에서 `compareBy<File> { it.name }`를 매번 만들 필요는 없습니다. 정렬 의미가 상태와 무관하면 하나의 불변 비교자를 재사용할 수 있습니다.
**조치:** 파일명 비교자를 최상위 `private val`로 한 번 생성하고 `process_dir`의 정렬에서 재사용합니다. 정렬 순서와 파일 시스템 경계는 변경하지 않습니다.
3 changes: 2 additions & 1 deletion src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ li + li {
""".trimIndent()

private val STYLE_HASH = "sha256-" + Base64.getEncoder().encodeToString(MessageDigest.getInstance("SHA-256").digest(CSS_CONTENT.toByteArray(Charsets.UTF_8)))
private val FILE_NAME_COMPARATOR = compareBy<File> { it.name }

class Html4tree : CliktCommand() {
val maxLevel:Int by option(help="Number of levels deep for which to generate an index.html file", hidden = false).int().default(-1)
Expand Down Expand Up @@ -404,7 +405,7 @@ fun process_dir(curr_dir: File, excludeSet: Set<String>? = null, dirFiles: Array

val filesList = dirFiles ?: curr_dir.listFiles()
val dir_files: MutableList<File> = filesList?.toMutableList() ?: mutableListOf()
dir_files.sortWith(compareBy ({it.name}) )
dir_files.sortWith(FILE_NAME_COMPARATOR)
dir_files.forEach {
val fileName = it.getName()
// ⚡ Bolt Performance Optimization: Short-circuit string match before expensive OS filesystem calls
Expand Down
Loading