Skip to content

Instantly share code, notes, and snippets.

Ole Begemann ole

Block or report user

Report or block ole

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@NikolaiRuhe
NikolaiRuhe / JSONValue.swift
Created Oct 15, 2018
JSON DOM Swift implementation
View JSONValue.swift
import Foundation
/// A JSONValue is a generic DOM representation of decoded JSON.
enum JSONValue {
case null
case boolean(Bool)
case number(Double)
case string(String)
case array(JSONArray)
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active Nov 17, 2019
Making efficient use of the libdispatch (GCD)
View libdispatch-efficiency-tips.md

libdispatch efficiency tips

I suspect most developers are using the libdispatch inefficiently due to the way it was presented to us at the time it was introduced and for many years after that, and due to the confusing documentation and API. I realized this after reading the 'concurrency' discussion on the swift-evolution mailing-list, in particular the messages from Pierre Habouzit (who is the libdispatch maintainer at Apple) are quite enlightening (and you can also find many tweets from him on the subject).

My take-aways are:

View Class Clusters
As of iOS 11/macOS High Sierra, and only including ones in Foundation and CoreFoundation
Strings:
_NSCFString - a CFStringRef or CFMutableStringRef. This is the most common type of string object currently.
- May have 8 bit (ASCII) or 16 bit (UTF-16) backing store
_NSCFConstantString - a compile time constant CFStringRef, like you'd get with @"foo"
- May also be generated by dynamic string creation if matches a string in a pre-baked table of common strings called the StringROM
NSBigMutableString - an NSString backed by a CFStorage (https://github.com/opensource-apple/CF/blob/master/CFStorage.h) for faster handling of very large strings
NSCheapMutableString - a very limited NSMutableString that allows for zero-copy initialization. Used in NSFileManager for temporarily wrapping stack buffers.
View build-options.sh
# When I want to attach lldb to swiftc to see how it works when compiling simple Swift programs:
utils/build-script \
--release --debug-swift \
--build-swift-dynamic-stdlib=0 --build-swift-dynamic-sdk-overlay=0 \
--skip-build-osx --skip-build-ios --skip-build-tvos --skip-build-watchos
# When I want to run the Swift test suite, to make sure my pull request would pass CI:
utils/build-script \
--release --debug-swift \
--test
You can’t perform that action at this time.