上一页 1 2 3 4 5 6 7 8 ··· 30 下一页

2019年3月20日

摘要: Native strings have tail-allocated storage, which begins at an offset of nativeBias from the storage object's address. String literals, which reside in the constant section, are encoded as their start... 阅读全文
posted @ 2019-03-20 07:57 花老🐯 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 对于普通的字符串,对应的_StringObject 有两个存储属性:_countAndFlagsBits: UInt64_object: Builtin.BridgeObject_countAndFlagsBits存储者字符串的长度和一些标记位。 ┌─────────┬───────┬──────────────────┬─────────────────┬────────┬───────┐│ ... 阅读全文
posted @ 2019-03-20 07:56 花老🐯 阅读(317) 评论(0) 推荐(0) 编辑
摘要: small string, 只有两个 UInt64 的字,这里面存储了所有的信息。内存布局如下:第二个 UInt64存储了标记位和长度信息,以及部分字符串的值 // Get an integer equivalent to the _StringObject.discriminatedObjectRawBits // computed property. @inlinable @inli... 阅读全文
posted @ 2019-03-20 07:56 花老🐯 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 最终都要走到__StringStorage 的 create(realCodeUnitCapacity,countAndFlags) 方法里去。 默认实现是 UTF8 internal static func _fromCodeUnits( _ input: Input, encoding: Encoding.Type, repair: Bool ) -> (String... 阅读全文
posted @ 2019-03-20 07:56 花老🐯 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 感受一下字符串相关的源文件个数String 概览是一个结构体只有一个变量,类型是 _StringGuts如上所示,String 真正的内容在__StringStorage或者__SharedStringStorage里面。 private static func create( realCodeUnitCapacity: Int, countAndFlags: CountAndFl... 阅读全文
posted @ 2019-03-20 07:55 花老🐯 阅读(497) 评论(0) 推荐(0) 编辑

2019年3月4日

摘要:   SequenceA type that provides sequential, iterated access to its elements.是最基础的协议,可以通过迭代来获取它的元素。有两个关联类型: /// A type representing the sequence's elements. associatedtype Element /// A type that... 阅读全文
posted @ 2019-03-04 08:25 花老🐯 阅读(350) 评论(0) 推荐(0) 编辑

2019年2月22日

摘要: 准备工作买一台 mac下载并安装 Xcode下载源码git clone git://git.webkit.org/WebKit.git WebKit这个可能要耗费很久很久编译源码打开 Xcode 为 ios 模拟器 build 命令行工具的权限sudo ./WebKit/Tools//Scripts/configure-xcode-for-ios-development否则,会报错如下 targe... 阅读全文
posted @ 2019-02-22 23:05 花老🐯 阅读(1618) 评论(1) 推荐(0) 编辑

2019年1月19日

摘要: Object Scopes 指定了生成的实例在系统中是如何被共享的。 如何指定 scopecontainer.register(Animal.self) { _ in Cat() } .inObjectScope(.container)例子如上,每次 register 方法,都会返回 ServiceEntry 实例,然后调用其 inObjectScope 方法,会设置其 objectSco... 阅读全文
posted @ 2019-01-19 21:03 花老🐯 阅读(702) 评论(0) 推荐(0) 编辑
摘要: 可能存在循环依赖,比如 Parent 强制有 Child, Child 弱持有 Parent。具体实现如下。Parent 初始化时,必须传入 Child,而 Child 初始化不必传入 Parent。protocol ParentProtocol: AnyObject { }protocol ChildProtocol: AnyObject { }class Parent: ParentProto... 阅读全文
posted @ 2019-01-19 21:03 花老🐯 阅读(654) 评论(0) 推荐(0) 编辑
摘要: 核心是 Container类。它提供了两类方法,register 和 resolve。 为了找到在 resolve 时,能够找到对应的方法,内部维护了一个叫做services 的字典。key 是根据 serviceType、name、argumentsType 确定的。在 register 时,会字典里加入一个条目。在 resolve 时,会根据字典,找到对应的 ServiceEntryPro... 阅读全文
posted @ 2019-01-19 21:01 花老🐯 阅读(911) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 30 下一页

导航