CommunityNews

CommunityNews

The Swift Array Design

Goals

  1. Performance equivalent to C arrays for subscript get/set of non-class element types is the most important performance goal.
  2. It should be possible to receive an NSArray from Cocoa, represent it as an Array<AnyObject>, and pass it right back to Cocoa as an NSArray in O(1) and with no memory allocations.
  3. Arrays should be usable as stacks, so we want amortized O(1) append and O(1) popBack. Together with goal #1, this implies astd::vector-like layout, with a reserved tail memory capacity that can exceed the number of actual stored elements.

To achieve goals 1 and 2 together, we use static knowledge of the element type: when it is statically known that the element type is not a class, code and checks accounting for the possibility of wrapping an NSArray are eliminated. An Array of Swift value types always uses the most efficient possible representation, identical to that of ContiguousArray

https://github.com/apple/swift/blob/main/docs/Arrays.rst

This thread was posted by one of our members via one of our news source trackers.

Popular Macos topics Top

AstonJ
This is a good guide about what to look for when getting a retina/non-retina monitor for your Mac. In short, around 110PPI is a good fit...
New
AstonJ
Nice to see the chip space being shook up - look forward to when we have 64 Core+ chips in our personal computers :nerd_face: Also good ...
New
New
First poster: bot
We’ll guide you through the process of using Homebrew package manager to install security tools on macOS to exploit vulnerabilities found...
New
First poster: bot
Yesterday, a short Twitter thread by the excellent Jeff Johnson caught my eye. Since he often deletes past tweets, I’ll quote the relevan...
New
CommunityNews
We’re all familiar with the Mac’s startup chime. While it has changed over the years, it has greeted users with its friendly tone for dec...
New
First poster: bot
The story of Apple CEO Steve Jobs is one of the most familiar in American business — shaggy Bob-Dylan-loving kid starts a computer compan...
New
First poster: bot
Every developer should watch the 5 videos about DocC from WWDC. But it’s really a plaintive cry for help. Until Apple squares up and addr...
New
First poster: bot
Learn how to use the brand new actor model to protect your application from unwanted data-races and memory issues.
New
First poster: bot
TLDR; I realised that my life while using Apple products is controlled by Product Managers/Owners who want to get a raise, rather than ...
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
DevotionGeo
I know that these benchmarks might not be the exact picture of real-world scenario, but still I expect a Rust web framework performing a ...
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
Margaret
Hello content creators! Happy new year. What tech topics do you think will be the focus of 2021? My vote for one topic is ethics in tech...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File &gt; New Rule: And select Deny, O...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New