
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 Mac Os topics

We all knew it was coming…
What do you think?
Apple has confirmed it will transition its Mac laptop and desktop computers to its own A...
New

Hi there!
I am a new iMac user (this is the first Apple’s product for me), and I am wondering should I update the mac OS system to the n...
New

I have a new MacBook Pro which I’m connecting to an external monitor. I know why it is heating but I want to know if anyone having the sa...
New

Hi there!
I wonder what is better for performance and “longevity” for iMac: should it be turned off through “Shut down” or should I put ...
New

Over the past decade, a large and opaque industry has been amassing increasing amounts of personal data.1,2
A complex ecosystem of websi...
New

hello (also known as helloSystem ) is a desktop system for creators with focus on simplicity, elegance, and usability. Its design follows...
New

Vitals is a little Mac app I built recently that shows you which programs are slowing your computer down. It lives in the menu bar, keepi...
New

I am intending to show an alert message in macOS through a C++ based application. I am using CFUserNotificationDisplayAlert for the same....
New

Hello, Apple developers!
I want to upload an app to testflight, but I’m having the issue from the picture and I can’t get around it.
Ha...
New

Just looking through my settings and noticed that Help Apple Improve Search was checked - yet I am almost certain that I did not opt-in 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

I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
New

Do the test and post your score :nerd_face:
:keyboard:
If possible, please add info such as the keyboard you’re using, the layout (Qw...
New

Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New

Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New

This is going to be a long an frequently posted thread.
While talking to a friend of mine who has taken data structure and algorithm cou...
New

We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New

Was just curious to see if any were around, found this one:
I got 51/100:
Not sure if it was meant to buy I am sure at times the b...
New

Author Spotlight:
David Bryant Copeland
@davetron5000
We’re so happy to bring you another Author Spotlight, a series where we sit dow...
New

Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
New
Latest in macOS
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /c
- /slackware
- /julia
- /neovim