Performance of let vs var

Currently if I have an Array to show in UITableView , which I am not going to modify the best bet is to use a constant array let.

However , how do we understand the performance advantages of using a let vs var ?

1 Like

how do we understand the performance advantages of using a let vs var ?

I don’t worry about performance at this level. Rather, I approach this from a semantic perspective, using let if the data is immutable. That’ll make the code easier to maintain going forwards.

If my product doesn’t meet its performance goals I then profile the code to discover the hotspots. My experience is that my intuition about what will be slow is often incorrect, and thus it’s best to optimise based on profiling results.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

7 Likes

Are 'the lazy mapping collection' and 'explicitly define capacity for the arrays' two main sticks for improving performance on Swift?