Skip to content

Minor code cleanups: duplicated helpers and per-row fuzzy loops #282

Description

@dfalster

A few small, low-risk cleanups noticed during review:

1. Duplicated gsub helper

The identical f <- function(x, find, replace) gsub(find, replace, x, perl = TRUE) is defined in three places: standardise_names(), strip_names(), and strip_names_extra() (R/standardise_names.R, R/strip_names.R). Promote to a single internal helper.

2. Repeated slash-pattern predicate

The slash/digit/paren/apostrophe detection in match_taxa() is repeated verbatim across the five match_04* branches (lines ~586, 633, 672, 711, 751). Compute once into a column.

3. Per-row fuzzy loops

Several fuzzy-match steps use for (i in seq_len(nrow(...))) to fill a column one element at a time (match_taxa.R ~784, 825, 1092, 1138). vapply()/purrr::map_chr() would be clearer and pre-allocate.

None of these change behaviour; all are covered by the existing alignment benchmark + snapshot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions