Jump to content




My window API is laggy


  • You cannot reply to this topic
2 replies to this topic

#1 EveryOS

  • Members
  • 570 posts
  • LocationOver there ->

Posted 24 June 2016 - 07:49 PM

I have the following code:
Code


It is very laggy when I run it with a repetitive function such as write.
As you can see, I removed all original os.pullEvent and coroutine.yield s in attempt to reduce lag.
Why does it lag and how do I fix it?

Edited by EveryOScrisp5dollarBill, 24 June 2016 - 07:53 PM.


#2 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 26 June 2016 - 06:59 AM

The most glaring issue is that any time anything is written to your buffer, you redraw the whole thing onto the screen - not just the bit that needs to be updated. You'd be better off rigging the blit function to do its own drawing if the window is "visible".

In the update function, it'd be faster to make use of table.concat() to merge line contents in a single go, rather than concatenating over and over again within a loop.

In your blit function, you've got a loop starting from 0 when it should start from 1. The regular blit function doesn't handle line breaks, either - nothing in the term API does. At some point you'll also have to think about what to do if the cursor is ever out of bounds.

#3 EveryOS

  • Members
  • 570 posts
  • LocationOver there ->

Posted 07 July 2016 - 07:18 PM

thx





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users