I have a program that performs many swapAt(::) calls on an
Array, where Memo is a class I define. In principle, it seems
that when swapAt returns, the Memos that change place should never have
a different number of references than when swapAt began. I had hoped
that the compiler would infer the constancy of the reference counts and
emit no retains or releases. However, my performance profile shows
swapAt calling retain and release, malloc and free.
I have a couple of questions about this:
Can I give a hint in my source code that will help the compiler to avoid
needless retains/releases in swapAt?
I am building my project with
swift run -c release Records .... It is
my understanding that
-c release will enable optimization. (I have
-Xswiftc -O---no difference.) Can I use a higher level of
optimization that will eliminate unnecessary retains and releases?