-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 copying in ASTextNode2 stack #1065
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
- (id)copyWithZone:(NSZone *)zone { | ||
ASTextContainer *one = [self.class new]; | ||
- (id)copyForced:(BOOL)forceCopy | ||
{ | ||
dispatch_semaphore_wait(_lock, DISPATCH_TIME_FOREVER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why we use a semaphore as lock in this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was inherited from YYText where he did that. I actually really like it for small lock scopes. It's a lot faster than pthread mutex and there is a risk of priority inversion but it's much smaller since the waiting thread sleeps instead of spinning.
* Remove copying in text stack, make text container have an optional immutable mode * Changelog * Comment * Update CHANGELOG.md * Use new name * Import header
Make text rendering faster.