Skip to content
Open
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 @@ -62,3 +62,7 @@
## 2026-08-11 - Array의 toMutableList 할당 오버헤드 최적화
**학습:** 배열을 정렬하기 위해 `.toMutableList()`를 호출하면 새로운 `ArrayList` 객체와 내부 배열 객체가 할당되어 대규모 디렉토리를 순회할 때 가비지 컬렉션(GC) 부하를 유발합니다. 배열 복제가 필요한 경우 `.clone()`을 사용하면 하나의 배열 객체만 새로 할당되므로 더 효율적입니다.
**조치:** 디렉토리 파일 배열을 정렬하기 전에 복사할 때 `.toMutableList()` 대신 `.clone()`을 사용하여 불필요한 중간 컬렉션 할당을 제거하고 성능을 향상시켰습니다.

## 2026-09-15 - [문자열 조회 최적화를 통한 성능 향상]
**Learning:** `when (firstOrNull())`을 사용하면 핫 루프에서 문자를 확인할 때 객체 할당 오버헤드가 발생합니다.
**Action:** 빠른 불리언 평가를 위해 `firstOrNull()` 시퀀스 대신 길이를 명시적으로 검사하고 인덱스 0에 직접 접근합니다.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to this project are documented in this file.

### Added

- **Performance**: 문자열의 `isHiddenFile` 함수 내 객체 할당(sequence materialization) 제거

- Emit a `noindex, nofollow` robots meta preference on every generated
directory page, with the explicit boundary that supporting crawlers must
first fetch the page and that confidential data still requires server-side
Expand Down
12 changes: 12 additions & 0 deletions patch_main_comment.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- src/main/kotlin/html4tree/main.kt
+++ src/main/kotlin/html4tree/main.kt
@@ -223,8 +223,10 @@
}

fun String.isHiddenFile(): Boolean {
+ // ⚡ Bolt Performance Optimization: Replace firstOrNull() with isEmpty() + this[0]
+ // avoiding Char? boxing and object allocation in a hot loop directory enumeration.
if (this.isEmpty()) return false
val c = this[0]
return c == '.' || c == '\u3002' || c == '\uFF0E' || c == '\uFF61'
}
9 changes: 5 additions & 4 deletions src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,11 @@ internal fun crawl_directories(
}

fun String.isHiddenFile(): Boolean {
return when (firstOrNull()) {
'.', '\u3002', '\uFF0E', '\uFF61' -> true
else -> false
}
// ⚡ Bolt Performance Optimization: Replace firstOrNull() with isEmpty() + this[0]
// avoiding Char? boxing and object allocation in a hot loop directory enumeration.
if (this.isEmpty()) return false
val c = this[0]
return c == '.' || c == '\u3002' || c == '\uFF0E' || c == '\uFF61'
}

// ⚡ Bolt Performance Optimization: Single-pass loop with lazy StringBuilder
Expand Down
18 changes: 18 additions & 0 deletions src/test/kotlin/html4tree/IsHiddenFileTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package html4tree

import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test

class IsHiddenFileTest {

@Test
fun `isHiddenFile should correctly identify hidden files`() {
assertTrue(".hidden".isHiddenFile())
assertTrue("\u3002hidden".isHiddenFile())
assertTrue("\uFF0Ehidden".isHiddenFile())
assertTrue("\uFF61hidden".isHiddenFile())
assertFalse("normal.txt".isHiddenFile())
assertFalse("".isHiddenFile())
}
}