Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions