From 2a53b0bd5df80f315df8bbfb422ccb93877a648f Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Tue, 11 Aug 2026 16:25:06 +0900 Subject: [PATCH 1/2] perf: build file-name array without intermediate list --- src/main/kotlin/html4tree/main.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/html4tree/main.kt b/src/main/kotlin/html4tree/main.kt index f216498..a97a3f7 100644 --- a/src/main/kotlin/html4tree/main.kt +++ b/src/main/kotlin/html4tree/main.kt @@ -183,7 +183,9 @@ internal fun crawl_directories( continue } - val dirFilesNames = dirFiles?.map { it.name }?.toTypedArray() + val dirFilesNames = dirFiles?.let { files -> + Array(files.size) { index -> files[index].name } + } val exclude = processIgnoreFile(lle.file, dirFilesNames) if(maxLevel == -1 || currentLevel <= maxLevel) From b435cf10286d005fffa76c52638bd6bd4ef93afc Mon Sep 17 00:00:00 2001 From: Seongho Bae Date: Tue, 11 Aug 2026 16:25:29 +0900 Subject: [PATCH 2/2] docs: record direct file-name array boundary --- .jules/bolt.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.jules/bolt.md b/.jules/bolt.md index af2bfbf..6ba1174 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -54,3 +54,7 @@ ## 2026-08-11 - Comparator 객체 재사용 **학습:** 반복 호출되는 디렉터리 정렬 경계에서 `compareBy { it.name }`를 매번 만들 필요는 없습니다. 정렬 의미가 상태와 무관하면 하나의 불변 비교자를 재사용할 수 있습니다. **조치:** 파일명 비교자를 최상위 `private val`로 한 번 생성하고 `process_dir`의 정렬에서 재사용합니다. 정렬 순서와 파일 시스템 경계는 변경하지 않습니다. + +## 2026-08-11 - 파일명 배열 직접 생성 +**학습:** 파일 배열에서 이름 배열을 만들 때 `map(...).toTypedArray()`는 결과 배열 외에 중간 컬렉션도 생성합니다. 호출 경계가 이미 배열을 제공한다면 크기를 알고 있는 결과 배열을 직접 채울 수 있습니다. +**조치:** `crawl_directories`에서 `Array(files.size)`로 파일명 배열을 직접 생성합니다. 순서, null 처리, ignore 입력과 파일 시스템 호출 횟수는 변경하지 않습니다.