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
mikelxc/Workarounds-for-ARM-mac. This repository describes how I get most of my configurations work on the new Apple Silicon Mac - mikel...
New
First poster: bot
Library Extension helps you find library books, but it doesn’t work on Safari—yet. At WWDC 2020, Apple announced it was going to support...
New
First poster: bot
Safari supports WebGPU experimentally with WSL kernels. I wrote a simple tuner that tries to optimize matrix multiplication. If you have ...
New
First poster: bot
Apple announced that it would be moving from Intel processors to Arm-based Apple Silicon CPUs for Macs at WWDC 2020. The Apple Silicon-ba...
New
First poster: Maartz
Until its recent demise, Internet Explorer was the browser hated most by web developers. Internet Explorer is now a thing of the past, r...
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
First poster: bot
This sample code project demonstrates how to install and run macOS virtual machines on Apple Silicon using the Virtualization framework. ...
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
AstonJ
Well my dev environment started to mess up so thought it was time for a clean install - I’ve been meaning to do one for a while anyway. T...
New

Other popular topics Top

Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
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
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
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
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
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
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New