linkrope / dunit

xUnit Testing Framework for D
Boost Software License 1.0
37 stars 9 forks source link

assertArrayEquals performance and const improvement #1

Closed burner closed 11 years ago

burner commented 11 years ago

the passed in arrays can be const

the length to travel need only be computed once.

I have another commit in place to remove some redundancy and also to add printf style assert message which are extremely handy.

linkrope commented 11 years ago
  1. What problem is solved by adding const to T[] and U[] when T and U are template parameters? The template already accepts const and immutable arrays without extra const.
  2. Replaced for statement with intention-revealing foreach range statement. (But more to improve the readability than the performance of the code.)
burner commented 11 years ago
  1. You can be sure you don't change it while asserting for correctness.
  2. Actually both. This only computes the min once the other did it min(t.length, u.length) times. I see some performance waste there.