Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » DarkThemeCached
Re: DarkThemeCached [message #57075 is a reply to message #57074] Fri, 21 May 2021 01:52 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1094
Registered: August 2007
Senior Contributor
To my understanding,

It keeps a little map (icolors = input colors, ocolors = output colors, total: 8 colors);

When you call DarkThemeCached(c)

1) It looks up c in icolors.(keys)
2) If it finds it, it returns the corresponding alternate (dark) theme color, ocolor (values).
3) If it couldn't find it in the keys, then calls DarkTheme(c) to calculate the dark theme color (ocolor). (relatively expensive)
4) Then it puts the new dark theme color variant into the map value and returns it.

Now, probably the confusing part is the index: "cache" structure seems to keep track of the current position, so that it wouldn't overwrite the last cached and used color unless it is necessary. That line with modulo operation is apparently for this purpose.
It will start over from index position 0 only if it is iterated enough ( >= 8 ), i, e. previous lookups failed to find their respective color 'c' value among the keys.

Keep in mind that this is what I see in this piece of code. Not the official explanation. Smile

Best regards,
Oblivion



[Updated on: Fri, 21 May 2021 02:06]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Deprecating THISBACK
Next Topic: Small optimization
Goto Forum:
  


Current Time: Mon May 13 18:00:57 CEST 2024

Total time taken to generate the page: 0.02426 seconds