moov-io / ach

ACH implements a reader, writer, and validator for Automated Clearing House (ACH) files. The HTTP server is available in a Docker image and the Go package is available.
https://moov-io.github.io/ach/
Apache License 2.0
455 stars 154 forks source link

merge: lineCount can be improved #862

Closed adamdecaf closed 3 years ago

adamdecaf commented 3 years ago

ACH Version: v1.6.2

What were you trying to do? When calling MergeFiles there's a function called lineCount that is used for when ACH files reach their Nacha designated limits. This is used to comply with Nacha guidelines that limit file lengths to 10k lines.

What did you expect to see? The implementation of lineCount is a) inefficient and b) requires the file completes a call to Create() without error.

What did you see? lineCount should be as fast as possible. On large arrays of files the performance will not be optimal.

adamdecaf commented 3 years ago

@vxio I started this on a branch, but wanted your thoughts. It reimplements some logic in Writer to fully process the structs, but we can manage that as that logic won't change.

https://github.com/adamdecaf/ach/blob/34b9274b4d8a48fd20c374032a0293da1e3ec93a/merge.go#L133

vxio commented 3 years ago

I'll take a look 👍🏻