Optimize space#16
Conversation
|
Interesting! Could you give me a really brief description of what your changes do? |
|
First of all,the k = x - y, so k is in [-M,N] // before
var vertices = Array(repeating: -1, count: 2 * Int(max) + 1) // from [0...2*max], it is -max...max in the whitepaper
// after
var vertices = Array(repeating: -1, count: max + 1) // from [0...N+M], it is -M...N in the whitepaperAnd then, I thing we should skip when the k is not in [-M,N] guard k >= -toCount && k <= fromCount else {
continue
}last,I think force unwraps is not the good choose,so i change the ! to ?? if traceType == .insertion {
let x = traceStep.nextX!
let x = traceStep.nextX ?? -1
return Trace(from: Point(x: x, y: x - k - 1), to: Point(x: x, y: x - k), D: D)
} else {
let x = traceStep.previousX! + 1
let x = (traceStep.previousX ?? 0) + 1
return Trace(from: Point(x: x - 1, y: x - k), to: Point(x: x, y: x - k), D: D)
} |
|
Thanks for the run down @Damonvvong - I was referring to the impact upon memory use, performance, etc. I should have been more specific in my language. |
|
Sorry, I don't konw what you want. |
|
Please accept my apologies, @Damonvvong - I was only interested in what functional changes there might be in performance and behaviour after merging your changes. I have not had time to properly review and run tests against what you've contributed yet. |
No description provided.