influxdb-client-csharp icon indicating copy to clipboard operation
influxdb-client-csharp copied to clipboard

feat: Use IEnumerable in WriteApi to eliminate unnecessary memory all…

Open birdalicious opened this issue 1 year ago • 4 comments

Proposed Changes

Change WriteApi to use IEnumerable for collection arguments instead of List. Change WriteRecords(List<string> records) to WriteRecords(IEnumerable<string> records)

Calling ToList on a collection will incur a memory allocation as the data is copied to the new list. Making the argument IEnumerable means ToList doesn't need to be called and so no extra memory allocation. Internally this will eliminate the unnecessary memory allocation in WriteRecords(string[] record) call to ToList, and client code also won't have to make the allocation if their data isn't already in a List## Checklist

Checklist

  • [x] CHANGELOG.md updated
  • [x] Rebased/mergeable
  • [x] A test has been added if appropriate
  • [ ] dotnet test completes successfully
  • [x] Commit messages are conventional
  • [x] Sign CLA (if not already signed)

birdalicious avatar Feb 15 '24 13:02 birdalicious