
CommunityNews
The Swift Array Design
Goals
- Performance equivalent to C arrays for subscript get/set of non-class element types is the most important performance goal.
- It should be possible to receive an
NSArray
from Cocoa, represent it as anArray<AnyObject>
, and pass it right back to Cocoa as anNSArray
in O(1) and with no memory allocations.- Arrays should be usable as stacks, so we want amortized O(1) append and O(1) popBack. Together with goal #1, this implies a
std::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. AnArray
of Swift value types always uses the most efficient possible representation, identical to that ofContiguousArray
…
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

Forbidden Commands to Speed Up macOS.
First, ask yourself, would you like to undo a decade of security protections painstakingly created...
New

What is ownership?
Ownership is the responsibility of some piece of code to eventually cause a value to be destroyed. An ownership system...
New

Safari supports WebGPU experimentally with WSL kernels. I wrote a simple tuner that tries to optimize matrix multiplication. If you have ...
New

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

Over the past few years, Apple seems increasingly willing to cooperate with authoritarian governments, uninterested in protecting its own...
New

Doing high-performance 3D rendering on the Web has always been a tricky proposition.
WebGL, in its quest for programmer familiarity and ...
New

Swift 5.5 is here with Xcode 13 Beta and with it comes my favorite new addition to Swift: Async/Await.
Async/await is a high level, stru...
New

This article is about how I found a vulnerability on Apple forgot password endpoint that allowed me to takeover an iCloud account. The vu...
New

Safari isn’t protecting the web, it’s killing it.
There’s been a lot of discussion recently about how “Safari is the new IE” (1, 2, 3, 4...
New

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
Other popular topics

Any thoughts on Svelte?
Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New

Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New

We have a thread about the keyboards we have, but what about nice keyboards we come across that we want? If you have seen any that look n...
New

Inspired by this post from @Carter, which languages, frameworks or other tech or tools do you think is killing it right now? :upside_down...
New

Think Again 50% Off Sale »
The theme of this sale is new perspectives on familiar topics.
Enter coupon code ThinkAgain2021 at checkout t...
New

Author Spotlight
Rebecca Skinner
@RebeccaSkinner
Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New

Author Spotlight:
Tammy Coron
@Paradox927
Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New

Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New

I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc.
However, I don’t...
New

This is a very quick guide, you just need to:
Download LM Studio: https://lmstudio.ai/
Click on search
Type DeepSeek, then select the o...
New
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /onivim
- /svelte
- /typescript
- /crystal
- /kotlin
- /c-plus-plus
- /tailwind
- /gleam
- /ocaml
- /react
- /elm
- /flutter
- /vscode
- /ash
- /opensuse
- /centos
- /php
- /deepseek
- /html
- /zig
- /scala
- /sublime-text
- /lisp
- /textmate
- /nixos
- /debian
- /react-native
- /agda
- /kubuntu
- /arch-linux
- /django
- /revery
- /ubuntu
- /manjaro
- /spring
- /nodejs
- /diversity
- /lua
- /c
- /julia
- /slackware
- /neovim