I am currently making an html-based editor, i know there are lots of editors out there especially html based but i want to do it myself once. What i am concerned about is, for e.g, when a user press a key, following operations will happen.
- check if some text in the editor is already selected, if selected delete that text first. and push this action in undo stack.
- input this character which also includes manipulating the array and then re rendering the line.
Now these two tasks alone can include so many function calls, like deletion alone will check which text is selected then it delete that text which will manipulate the arrays and re-render the lines and so on.
If I break down this code into a readable form, there are lots of function calls on just a key press and u know user does not have to just press on key, if I dont break the code into a readable form this will make the complex and a lot of code will be repeated. What is the good practice ? to make the code more complex and have less function calls or to make the code readable and have more functions ?