Optionally use perfect hashing for field path matching in derive macro `apply`
Field paths are serialized as strings, and applying a diff to a large struct can be costly due to excessive string matching. It should be possible to leverage one of the crates in the ecosystem for perfect hashing when generating code for apply in the derive macro.
@kabergstrom What about using field indices instead of field names, like with tuples? This would reduce the size & cpu usage the most.
I implemented that here: https://github.com/amethyst/serde-diff/commit/5afe403d0d4fb80f5d072f4836f1a72bf6da6dff
Ah, nice! And how to enable that for a struct?
Use Diff::serializable_with_mode(old, new, FieldPathMode::Index) instead of Diff::serializable. I don't like this API though, I want to it to be more like a Config struct so that adding/removing options doesn't break people's code. Just haven't gotten to it yet
Above comment has become:
let diff = Config::new()
.with_field_path_mode(FieldPathMode::Index)
.serializable_diff(&old, &new);