Skip to main content

Writing High-Performance Swift Code

  • Enabling Optimizations
  • Whole Module Optimizations (WMO)
  • Reducing Dynamic Dispatch
  • Dynamic Dispatch
    • Advice: Use 'final' when you know the declaration does not need to be overridden
    • Advice: Use 'private' and 'fileprivate' when declaration does not need to be accessed outside of file
    • Advice: If WMO is enabled, use 'internal' when a declaration does not need to be accessed outside of module
  • Using Container Types Efficiently
    • Advice: Use value types in Array
    • Advice: Use ContiguousArray with reference types when NSArray bridging is unnecessary
    • Advice: Use inplace mutation instead of object-reassignment
  • Wrapping operations
    • Advice: Use wrapping integer arithmetic when you can prove that overflow cannot occur
  • Generics
    • Advice: Put generic declarations in the same module where they are used
  • The cost of large Swift values
    • Advice: Use copy-on-write semantics for large values
  • Unsafe code
    • Advice: Use unmanaged references to avoid reference counting overhead
  • Protocols
    • Advice: Mark protocols that are only satisfied by classes as class-protocols
  • The Cost of Let/Var when Captured by Escaping Closures
    • Advice: Pass var as an inout if closure not actually escaping
  • Unsupported Optimization Attributes

Comments

Most Favorite Posts

j2obc - A Java to iOS Objective-C translation tool and runtime

What J2ObjC Is J2ObjC is an open-source command-line tool from Google that translates Java code to Objective-C for the iOS (iPhone/iPad) platform. This tool enables Java code to be part of an iOS application's build, as no editing of the generated files is necessary. The goal is to write an app's non-UI code (such as data access, or application logic) in Java, which is then shared by web apps (using GWT), Android apps, and iOS apps. J2ObjC supports most Java language and runtime features required by client-side application developers, including exceptions, inner and anonymous classes, generic types, threads and reflection. JUnit test translation and execution is also supported. J2ObjC is currently between alpha and beta quality. Several Google projects rely on it, but when new projects first start working with it, they usually find new bugs to be fixed. Apparently every Java developer has a slightly different way of using Java, and the tool hasn't translated all possib...

PlistBuddy

If you want to generate a Plist within the shell script: The PlistBuddy command is used to read and modify values inside of a plist. Unless specified by the -c switch, PlistBuddy runs in interactive mode. Apple PlistBuddy ManPage

Google Drive versus Dropbox

MacWorld: Online Storage Face-Off: Google Drive vs. Dropbox

Why The Microsoft Surface Just Died Last Week

That was when the company’s new CEO, Satya Nadella, announced the launch of Office for the iPad. He emphasized the company’s focus on cloud and mobile for the future. “We think about users both as individuals and organizations spanning across all devices,” Nadella said during the launch event. And what he said effectively killed the Microsoft Surface. Forbes.com

App Indexing

A better search experience for apps and users with linking to in-app content. Google is working with app developers and webmasters to index the content of apps and relate them to websites. When relevant, Google Search results on Android will include deep links to apps. App Indexing

MobileIron

Advanced Mobile Device Management Mobile Data Security, Visibility and Control for Enterprises Phones are replaceable. Data is not. Advanced Mobile Device Management combines traditional mobile device management capabilities with advanced data visibility and control powered by the Virtual Smartphone Management Platform architecture. The administrator can manage the lifecycle of the phone and its data, from registration to retirement, and quickly get smartphone operations under control. Tour the Enterprise Smartphone Management Dashboard. Multi-OS Device Management Central web-based console across operating systems Inventory and asset management Device configuration Encryption policy (phone, SD) Lockdown security (camera, SD, Bluetooth, Wi-Fi) Password enforcement Remote lock and wipe File distribution End-user self-service App Management Inventory Secure publishing and delivery Rogue app protection Remote Control Real-time, permission-based Enterprise Data Bo...

CFPropertyList

The PHP implementation of Apple's PropertyList plist can handle XML PropertyLists as well as binary PropertyLists. It offers functionality to easily convert data between worlds, e.g. recalculating timestamps from unix epoch to apple epoch and vice versa. A feature to automagically create (guess) the plist structure from a normal PHP data structure will help you dump your data to plist in no time. github