Skip to content

perf: withRepo/fn-impact.ts has the same double-loadConfig pattern as withReadonlyDb #1941

Description

@carlos-alm

Follow-up from PR #1883's Greptile review (#1883 (comment)... — comment on src/domain/analysis/query-helpers.ts:19).

That PR fixed withReadonlyDb + its callers (exports.ts, context.ts) to resolve config once via the new resolveDbConfig() export and pass it through to resolveAnalysisOpts({ ...opts, config: opts.config ?? config }), avoiding a redundant loadConfig() call per query.

fn-impact.ts has the identical pattern but through the withRepo path instead:

  • withRepo(customDbPath, fn)openRepo(customDbPath)resolveDbSettings(customDbPath, opts.engine)loadConfig(deriveRootDirFromDbPath(customDbPath))
  • fn-impact.ts:280 then separately calls resolveAnalysisOpts(opts), which calls loadConfig() again (cwd-rooted) when opts.config is absent.

Fixing this is out of scope for #1883 because openRepo/resolveDbSettings in db/connection.ts are used by every native-engine call site (not just read-only analysis queries), so widening withRepo's callback signature to also pass config has a much larger blast radius than withReadonlyDb's change. Worth doing as its own focused PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions