|
|
|
|
|
by maoeurk
2234 days ago
|
|
Assuming this was run on a 64bit system, the Rust version seems to be allocating and zeroing twice as much memory as the Go version. edit: this has been pointed out as incorrect, Go ints are 8 bytes on 64bit systems -- thanks for the correction! let mut cache: Vec<usize> = (0..=target.chars().count()).collect();
which can be simplified as let mut cache: Vec<usize> = vec![0; target.len()];
vs cache := make([]int, len(target)+1)
for i := 0; i < len(target)+1; i++ {
cache[i] = i
}
Rust usize being 8 bytes and Go int being 4 bytes as I understand it.So between doing more work and worse cache usage, it wouldn't be surprising if the Rust version was slower even with the faster allocator. |
|