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.

Where Next?

Popular Macos topics Top

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
After months of silence about Apple’s impressive M1 chip, Intel just clapped back with a carefully crafted takedown of the Arm-based chip...
New
First poster: bot
Hardware Security and Biometrics System Security Encryption and Data Protection App Security Services Security Network Sec...
New
First poster: bot
The Swift concurrency model intends to provide a safe programming model that statically detects data races and other common concurrency b...
New
First poster: bot
Swift is about to get its Concurrency features. Their development is going very well, with many proposals actively reviewed and a lot of ...
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
Learn how to use the brand new actor model to protect your application from unwanted data-races and memory issues.
New
First poster: bot
Apple Makes OS X Lion and Mountain Lion Free to Download. Apple recently dropped the $19.99 fee for OS X Lion and Mountain Lion, making ...
New
First poster: bot
First Look: macOS Monterey Public Beta. If there’s a theme of Apple’s operating-system releases in 2021, it’s platform unification. This...
New
First poster: bot
The release of M1 Macs marked a turning point for the open-source operating system community on Apple hardware. Now, the whole hardware s...
New

Other popular topics Top

AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
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
If you are experiencing Rails console using 100% CPU on your dev machine, then updating your development and test gems might fix the issu...
New
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
DevotionGeo
I have always used antique keyboards like Cherry MX 1800 or Cherry MX 8100 and almost always have modified the switches in some way, like...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New