> On May 30, 2017, at 3:36 PM, Jean-Daniel via swift-evolution > <[email protected]> wrote: > >> >> Le 30 mai 2017 à 12:42, Charlie Monroe via swift-evolution >> <[email protected] <mailto:[email protected]>> a écrit : >> >> There was someone a few weeks ago trying to port his Go game to Swift from >> (I believe) C++ and found out that the lack of fixed-size arrays was causing >> the move-computing algorithm to slow down significantly. >> >> This is due to fixed arrays being able to live on stack, while "normal >> Array" is dynamically allocated on heap, etc. > > Really ? Isn’t it due to the value semantic of swift arrays ? > > If this is the former, its algorithm can probably be tweak to reuse the array > and require less allocations. > > Unless if you algorithm is eager in memory allocation/deallocation, you > shouldn't get a significant difference between static array and dynamic array.
Eliminating the dynamic allocations and extra indirections caused by the Swift array implementation can make a huge difference, not just in itself, but it also gives the compiler more opportunities to optimize the code. In my code (Monte Carlo simulations for a Go-playing program) I was able to gain a factor of 5 by using the ugly workaround of importing fixed-size arrays from C. Anders
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
