diff --git a/CHANGELOG.md b/CHANGELOG.md index 71778727..b3703292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Sleep durations are now logged as Go-like duration strings (e.g. "10s") in either text or JSON instead of duration strings in text and nanoseconds in JSON. [PR #699](https://github.com/riverqueue/river/pull/699). - Altered the migration comments from `river migrate-get` to include the "line" of the migration being run (`main`, or for River Pro `workflow` and `sequence`) to make them more distinguishable. [PR #703](https://github.com/riverqueue/river/pull/703). +- Fewer slice allocations during unique insertions. [PR #705](https://github.com/riverqueue/river/pull/705). ### Fixed diff --git a/insert_opts.go b/insert_opts.go index 07e6409d..0efba19a 100644 --- a/insert_opts.go +++ b/insert_opts.go @@ -184,6 +184,13 @@ func (o *UniqueOpts) isEmpty() bool { var jobStateAll = rivertype.JobStates() //nolint:gochecknoglobals +var requiredV3states = []rivertype.JobState{ //nolint:gochecknoglobals + rivertype.JobStateAvailable, + rivertype.JobStatePending, + rivertype.JobStateRunning, + rivertype.JobStateScheduled, +} + func (o *UniqueOpts) validate() error { if o.isEmpty() { return nil @@ -209,13 +216,7 @@ func (o *UniqueOpts) validate() error { return nil } - requiredV3states := []rivertype.JobState{ - rivertype.JobStateAvailable, - rivertype.JobStatePending, - rivertype.JobStateRunning, - rivertype.JobStateScheduled, - } - missingStates := []string{} + var missingStates []string for _, state := range requiredV3states { if !slices.Contains(o.ByState, state) { missingStates = append(missingStates, string(state))