Skip to content

[SR-6197] Swift subclass of NSTextStorage is slow because of Swift bridging #48749

@swift-ci

Description

@swift-ci
Previous ID SR-6197
Radar None
Original Reporter fumoboy007 (JIRA User)
Type Bug

Attachment: Download

Environment

Apple Swift version 4.0 (swiftlang-900.0.65.2 clang-900.0.37)

Target: x86_64-apple-macosx10.9

macOS 10.13

Additional Detail from JIRA
Votes 2
Component/s Compiler, Standard Library
Labels Bug
Assignee None
Priority Medium

md5: d13ea9787b0d44984c429de46b2d6547

Issue Description:

`NSTextStorage` vs. `TextStorageSwiftSubclass`

Calling `-[NSTextStorage attributesAtIndex:effectiveRange:]` is nearly 3 times as slow for `TextStorageSwiftSubclass` compared to `NSTextStorage`. Time profiling shows that this is caused by the bridging of the Objective-C dictionary return value to Swift. Effectively, this means we cannot use Swift if we want to subclass `NSTextStorage`.

Sample project and time profiler trace are attached.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfperformancestandard libraryArea: Standard library umbrella

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions