LINBIT / drbdtop

CLI management tool for DRBD. Like top, but for DRBD resources.
GNU General Public License v2.0
47 stars 14 forks source link

Small optimization and code restructuring #19

Closed raltnoeder closed 4 years ago

raltnoeder commented 4 years ago

Commit 8c67b0876e2381af3c91647877e0e0b3180c0b96 avoids a duplicate map lookup. Should probably be applied.

Commit 3f6ebd6ad799602849ecd8cc85b3830c8e0e5faa restructures code, avoiding some code duplication for a special case. Low importance, this may be a somewhat cleaner solution than the existing one.

deleteriousEffect commented 4 years ago

I like 8c67b0876e2381af3c91647877e0e0b3180c0b96. It's obviously cleaner and cherry-picking it alone produces the best benchmark test results. Please make a PR of it alone against the development branch and I'll accept it.

I personally don't prefer 3f6ebd6ad799602849ecd8cc85b3830c8e0e5faa. While it's not common, I think that handling a special or end state case of a while loop with loop variables directly after the loop terminates is appropriate here. Here's an example from the standard library that I think is really nice: https://golang.org/src/sort/sort.go?s=6884:6908#L489

I'd rather keep it this way than having even moderately branching code as I tend to try to follow the recommendations in this article when and where I can: https://medium.com/@matryer/line-of-sight-in-code-186dd7cdea88

Also, @rck? should we do away with the development master split? It's different than our other projects and consistency is good. I'll leave that up to you!

raltnoeder commented 4 years ago

Ok, sounds good, I'll open another pull request with 8c67b08 for you to merge

rck commented 4 years ago

Thanks, then I close this one.