Skip to content

Improve: make text wrapping quicker#6277

Merged
vadi2 merged 2 commits intoMudlet:developmentfrom
hhsiao:Text-Wrapping-Optimization
Sep 6, 2022
Merged

Improve: make text wrapping quicker#6277
vadi2 merged 2 commits intoMudlet:developmentfrom
hhsiao:Text-Wrapping-Optimization

Conversation

@hhsiao
Copy link
Copy Markdown
Contributor

@hhsiao hhsiao commented Sep 2, 2022

Avoided duplicate call to horizontalAdvance, basically skip the first call since it was called before the function is called

Brief overview of PR changes/additions

horizontalAdvance is an expensive call, current implementation in binarySearchHorizontalAdvance has a duplicate call that happen when the function is called for the first time for the line being wrapped. This PR avoided that.

Motivation for adding to Mudlet

This would have reduce the horizontalAdvance call for line that needs to be wrapped as follow:
Wrapped 1 time : 50%
Wrapped 2 times : 33.3%
Wrapped 3 times : 25%
Wrapped 4 times : 20%
Wrapped 5 times : 16.6%
Wrapped 6 times : 14.28%
Wrapped 7 times : 12.5%
Basically, 1/(wrapped times + 1).

Other info (issues closed, discussion etc)

Avoided duplicate call to horizontalAdvance, basically skip the first call since it was called before the function is called
@hhsiao hhsiao requested a review from a team as a code owner September 2, 2022 03:52
@hhsiao hhsiao requested a review from a team September 2, 2022 03:52
@add-deployment-links
Copy link
Copy Markdown

add-deployment-links bot commented Sep 2, 2022

Hey there! Thanks for helping Mudlet improve. 🌟

Test versions

You can directly test the changes here:

No need to install anything - just unzip and run.
Let us know if it works well, and if it doesn't, please give details.

@mudlet-machine-account mudlet-machine-account added this to the 4.17.0 milestone Sep 2, 2022
@demonnic demonnic changed the title binarySearchHorizontalAdvance optimization Infrastructure: binarySearchHorizontalAdvance optimization Sep 2, 2022
@vadi2 vadi2 changed the title Infrastructure: binarySearchHorizontalAdvance optimization Improve: binarySearchHorizontalAdvance optimization Sep 2, 2022
@vadi2 vadi2 changed the title Improve: binarySearchHorizontalAdvance optimization Improve: make text wrapping quicker Sep 2, 2022
@vadi2
Copy link
Copy Markdown
Member

vadi2 commented Sep 2, 2022

LGTM. Will give others a few days to review and then we merge :)

@demonnic
Copy link
Copy Markdown
Member

demonnic commented Sep 2, 2022

I mentioned in discord but a 1000000 line test shows ~18% reduction in overall time taken to process.

@vadi2 vadi2 merged commit e9f5f97 into Mudlet:development Sep 6, 2022
demonnic added a commit that referenced this pull request Nov 12, 2022
demonnic added a commit that referenced this pull request Nov 14, 2022
#### Brief overview of PR changes/additions
#6207 and subsequently #6277 have since been discovered to be the source of several bugs, and so we have decided to revert the changes in development but open a new PR for the changes themselves.

#### Motivation for adding to Mudlet

#### Other info (issues closed, discussion etc)
resolve the following issues:
#6416
#6394 
#6321 
#6290

Co-authored-by: Kebap <kebap_spam@gmx.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants