Skip to content

find/replace strings re-allocated as []byte for every file #22

@dolph

Description

@dolph

Summary

rewriteContents calls rewriteFile(f.Path, []byte(fr.find), []byte(fr.replace), info.Mode()). The string[]byte conversion allocates per file. On a tree of N files we allocate N copies of the same find/replace bytes.

Trivially fixable: convert once when constructing findReplace (or store both forms).

Impact (Performance: Low)

  • Two small allocations per file. Negligible per file but observable on large trees.

Suggested Fix

Pre-compute []byte versions in the findReplace struct (or change find/replace field types to []byte).

Files

  • find_replace.go:101-120

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions