Closed gfoidl closed 1 year ago
The naming convention plugin is generally very non-perf-sensitive; it's only invoked when setting up the model, which occurs once on program startup (or even at design-time if you're using EF compiled models). So I wouldn't go into too much optimization here - especially if it makes things more complex or includes assumptions on name lengths etc. Let me know if you think that's worthwhile.
it's only invoked when setting up the model
Ah, I had a wrong assumption then. Thought it's used more often. Thanks for that info. So no need to optimize this.
In
RewriteName
there's always an allocation of https://github.com/efcore/EFCore.NamingConventions/blob/7f07dcce613ba5f67c92ec4d3357c14b461db79e/EFCore.NamingConventions/Internal/SnakeCaseNameRewriter.cs#L21As most names will be short that allocation(s)* could be avoided by using a stack-allocated char-buffer or a solution like ValueStringBuilder (copy & paste from dotnet/runtime-repo).
Is this something that you'd like me to try out in a PR?
* StringBuilder itself and the internal chunk(s) used by the SB