Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce startup time. #1288

Merged
merged 1 commit into from
Dec 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Source/ASTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,14 @@ @implementation ASTextNode {
}
@dynamic placeholderEnabled;

static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
static NSArray *DefaultLinkAttributeNames() {
static NSArray *names;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
names = @[ NSLinkAttributeName ];
});
return names;
}

- (instancetype)init
{
Expand All @@ -225,7 +232,7 @@ - (instancetype)init
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];

self.linkAttributeNames = DefaultLinkAttributeNames;
self.linkAttributeNames = DefaultLinkAttributeNames();

// Accessibility
self.isAccessibilityElement = YES;
Expand Down
15 changes: 11 additions & 4 deletions Source/ASTextNode2.mm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,14 @@ @implementation ASTextNode {
}
@dynamic placeholderEnabled;

static NSArray *DefaultLinkAttributeNames = @[ NSLinkAttributeName ];
static NSArray *DefaultLinkAttributeNames() {
static NSArray *names;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
names = @[ NSLinkAttributeName ];
});
return names;
}

- (instancetype)init
{
Expand All @@ -200,9 +207,9 @@ - (instancetype)init
// The common case is for a text node to be non-opaque and blended over some background.
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
self.linkAttributeNames = DefaultLinkAttributeNames;

self.linkAttributeNames = DefaultLinkAttributeNames();

// Accessibility
self.isAccessibilityElement = YES;
self.accessibilityTraits = self.defaultAccessibilityTraits;
Expand Down