Skip to content

La Famille / Field notes

La Famille Component Mapping & Micro-Improvement Audit

Part 1: Component Identification

Part 2: Micro-Improvements

Here are 3 localized high-ROI micro-improvements to consider:

  1. Optimize Map Pre-Allocation (internal/search/search.go): In ExtractHeadings, the seen map for tracking unique headings is allocated without a size hint. Since the number of headings is bounded by the number of lines (which is known from strings.Split), initializing with a proportional capacity or a small baseline (e.g., make(map[string]bool, 8)) can reduce early rehashing.
  2. Optimize Set Data Structures (internal/search/search.go): Convert the htmlElements map from map[string]bool to map[string]struct{}. Go’s empty struct consumes zero bytes, making it a more memory-efficient choice for static lookup sets than boolean values.
  3. Optimize Map Pre-Allocation (internal/render/render.go): In DiscoverLayouts, the entries, err := os.ReadDir(templateDir) call provides the exact number of files. By moving the allowlist := make(map[string]bool) initialization below it and using make(map[string]bool, len(entries)), you can avoid incremental map re-hashing during population.

Learnings