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

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
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
Malicious hackers have been exploiting a vulnerability in fully updated versions of macOS that allowed them to take screenshots on infect...
New
First poster: bot
Apple’s leaders continue to deny developers of two obvious truths: That our apps provide substantial value to iOS beyond the purchase c...
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
I’m a bit of a sustainability nerd. I love the idea of living a life where your carbon footprint is neutral (or negative) and you leave t...
New
First poster: bot
macOS has a wonderful input mechanism where you press and hold a key on your keyboard to display the accent menu. It’s easy to internaliz...
New
First poster: bot
Recommended settings for Wi-Fi routers and access points. For the best security, performance, and reliability, we recommend these settin...
New

Other popular topics Top

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
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
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
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New