Skip to content
Open
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@
## 2026-08-11 - Array의 toMutableList 할당 오버헤드 최적화
**학습:** 배열을 정렬하기 위해 `.toMutableList()`를 호출하면 새로운 `ArrayList` 객체와 내부 배열 객체가 할당되어 대규모 디렉토리를 순회할 때 가비지 컬렉션(GC) 부하를 유발합니다. 배열 복제가 필요한 경우 `.clone()`을 사용하면 하나의 배열 객체만 새로 할당되므로 더 효율적입니다.
**조치:** 디렉토리 파일 배열을 정렬하기 전에 복사할 때 `.toMutableList()` 대신 `.clone()`을 사용하여 불필요한 중간 컬렉션 할당을 제거하고 성능을 향상시켰습니다.
## 2024-03-24 - [Kotlin String.firstOrNull() Boxing Overhead]
**Learning:** Kotlin에서 문자열의 첫 글자를 확인할 때 `firstOrNull()`을 사용하면 `Char?`로 박싱(boxing)되면서 불필요한 객체 할당 오버헤드가 발생한다. 특히 파일 필터링과 같은 핫 루프(hot loop)에서는 누적된 가비지 컬렉션(GC) 부하를 유발한다.
**Action:** 성능에 민감한 핫 루프에서는 `isEmpty()` 확인 후 직접 인덱스(`this[0]`)로 접근하는 방식을 사용하여 시퀀스 구체화 및 박싱 오버헤드를 회피해야 한다.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ All notable changes to this project are documented in this file.

### Changed

- 성능 향상을 위해 `String.isHiddenFile()`의 `firstOrNull()` 호출을 제거하고 직접 인덱스 접근(`this[0]`)을 사용하여 객체 할당(boxing) 오버헤드 감소

- Improve generated directory-index readability with adjacent-row separators,
explicit light and dark empty-state text colors, and text-only hover/focus
underlining while retaining the full interactive target's focus outline.
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ internal fun crawl_directories(
}

fun String.isHiddenFile(): Boolean {
return when (firstOrNull()) {
if (this.isEmpty()) return false
return when (this[0]) {
'.', '\u3002', '\uFF0E', '\uFF61' -> true
else -> false
}
Expand Down