FLTK logo

Re: [fltk/fltk] Suggestion: pass the focus state as a parameter to `Fl_Input_::drawtext` (#211)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [fltk/fltk] Suggestion: pass the focus state as a parameter to `Fl_Input_::drawtext` (#211) Albrecht Schlosser Apr 07, 2021  
 

Fl_Input_::drawtext ... has repeated checks for whether Fl::focus() == this, ...

Your suggestion to add Fl::focus() == this as a boolean parameter: Fl::focus() is a very fast inline method, it's just a memory lookup - there's not much potential for optimization if that's what you want to achieve. Thoughts:

  • I don't think it's useful to add this extra argument - unless there's a compelling reason to pass a different information.
  • In fact someone could pass the wrong information.
  • Information hiding: the implementation doesn't require this argument, so don't force the caller to set it (there's no need to expose implementation details to the caller).
  • If we ever wanted to "optimize" that code we could store Fl::focus() == this in a local variable and subsequently use this variable.
  • The compiler would (probably) do this for us anyway, at least if compiled with optimization.

That said, I propose to close this issue. Thanks for your second suggestion which has been committed.

If you have more comments or questions, please feel free to comment - or to close this issue.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.