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 copying in ASTextNode2 stack #1065

Merged
merged 8 commits into from
Aug 7, 2018
Merged

Reduce copying in ASTextNode2 stack #1065

merged 8 commits into from
Aug 7, 2018

Conversation

Adlai-Holler
Copy link
Member

Make text rendering faster.

  • Remove pointless attributed string mutable copy in ASTextLayout. No clue why this was here but it is not useful in the least.
  • Provide an option to make ASTextContainers immutable and get free copying. ASTextLayout copies its container, which is often already a copy so we save that.

@TextureGroup TextureGroup deleted a comment Aug 4, 2018
@TextureGroup TextureGroup deleted a comment Aug 4, 2018
Copy link
Contributor

@maicki maicki left a 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);
Copy link
Contributor

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?

Copy link
Member Author

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.

@Adlai-Holler Adlai-Holler merged commit 03e6ce0 into master Aug 7, 2018
@Adlai-Holler Adlai-Holler deleted the AHSkipTextCopy branch August 7, 2018 15:32
mikezucc pushed a commit to mikezucc/Texture that referenced this pull request Oct 2, 2018
* Remove copying in text stack, make text container have an optional immutable mode

* Changelog

* Comment

* Update CHANGELOG.md

* Use new name

* Import header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants