Skip to content

/castfocus, /pfcastfocus: Optimize castfocus using superwow; also side-optimize and enhance /pfcast to employ memoization under the hood and support passing raw-lua-functions to it#1609

Closed
dsidirop wants to merge 156 commits intoshagu:masterfrom
dsidirop:dsidirop/PF-0029-optimize-castfocus-using-superwow

Conversation

@dsidirop
Copy link
Contributor

@dsidirop dsidirop commented Feb 15, 2026

  • Add support for superwow-aware SlashCmdList.PFCASTFOCUS() just like we did with SlashCmdList.PFFOCUS()

This allows us to employ unit-guid-targeting to side-step the complex target-swapping tricks we would resort to when superwow wasn't available.

This is a much more care-free and lightweight approach.

  • Replace loadstring() calls in _G.SlashCmdList.PFCAST() and SlashCmdList.PFCASTFOCUS() with the new pfUI.api.TryMemoizedFuncLoadstringForSpellCasts() to enjoy better runtime performance when the user passes lua-func-strings (considering that they're the same strings time and over again).

As an added bonus this commit also adds seamless support for passing actual raw functions to SlashCmdList.PFCASTFOCUS() ala:

SlashCmdList.PFCASTFOCUS(function() CastspellByName("Renew" .. desiredRank); end)

This is extremely useful for advanced pure-lua macros (p.e. via SuperMacro) as it simplifies the invocation-style tremendously.

Old was: Before this commit we would have to write this kind of stuff as a string

SlashCmdList.PFCASTFOCUS( 'function() CastspellByName("Renew"' .. desiredRank .. '); end' )  -- notice we had to use a "string-function" here!

This was both 10x slower and was extremely cumbersome and error-prone for the user if he wanted to pass some variable-state inside the string-func-callback (god help him in that case!)

Artur91425 and others added 30 commits February 9, 2024 19:52
   - pfUI.uf.mouseover now gets cached the first time the hook is triggered and if the mouseover module is disabled we set the cache to the empty object {} as a safety net

   - we now detect attempts to get the player's name via UnitName("player") and we simply return the 'player' variable we already have to save ourselves a function call

   - also removed a duplicate call to UnitName("target") which was unnecessary
…seAction" with that of "CastSpellByName" in terms of getting the proper unit-name

    these two post-hook functions now take the mouse-over value (if any) into account just like we do in the "CastSpellByName" post-hook
…libpredict-spell-cast-hooks

#1283 optimize and align libpredict spell cast hooks
…time and range components in the spell tooltip

   to fix this bug we had to pass 'false' as the 2nd argument to scanner:Find() to disable "exact matching" in it
…llinfo-for-ranges-and-casting-time

fix (libspell.lua): GetSpellInfo() now properly spots the spell-cast-time and range components in the spell tooltip
…rn-spell-id-and-book-type

feat (libspell): GetSpellInfo() now also returns the numeric-spell-id of the spell and its book-type
mapcolors: rewrite module implementation
   we intentionally differentiated the name as 'GetPlayerBuffX' (note the 'X' at the end) so as to ensure
   that we won't accidentally break 3rd party pfui-addons that import the pfUI environment expecting
   GetPlayerBuff() to work exactly like in vanilla in terms of its 1st parameter (which is not the case
   with GetPlayerBuffX())
…rBuffX() instead of GetPlayerBuff(PLAYER_BUFF_START_ID+...)
…uff-into-an-api-method

#6 Consolidate getplayerbuff into an api method
…uff-into-an-api-method

docs (api.lua): trivial doc-comment tweaks
… per iteration inside the 'debuff' section of :RefreshUnit()
…side the for-each-debuff loop of :RefreshUnit()
…uff-into-an-api-method

dsidirop/6 consolidate getplayerbuff into an api method
dsidirop added 26 commits June 8, 2025 02:27
…in pfUI.uf:EnableClickCast() for the sake of performance/readability
unitframes.lua: optimize a bit the way macro-scripts are detected in :ClickAction() (and to a minor degree in :EnableClickCast())
…List.PFFOCUSCAST() defined in focus.lua and employ it when the caller specifies a hard-coded spell

    if scriptlet/function is passed we fallback to the original approach considering that superwow doesn't (and probably will never) support func-scriptlets
…fUI.api.RunOOC() to resolve some static-analysis warnings about var-names
…ich is meant to be used in order to memoize lua-func-strings passed on to various spell-casting utilities in the next few commits (/pfcast, /castfocus etc)
…STFOCUS() just like we did with SlashCmdList.PFFOCUS

   this allows us to employ unit-guid-targeting to side-step the complex target-swapping tricks we would resort to when superwow wasn't available

   this is a much more care-free and lightweight approach
…alls in _G.SlashCmdList.PFCAST() and SlashCmdList.PFCASTFOCUS() with pfUI.api.TryMemoizedFuncLoadstringForSpellCasts() to enjoy better runtime performance when the user passes a lua-func-string

    as an added bonus this commit also adds seamless support for passing actual raw functions to SlashCmdList.PFCASTFOCUS() ala:

    SlashCmdList.PFCASTFOCUS(function() CastspellByName("Renew", 1); end)

    which is extremely useful for advanced pure-lua macros.

    Old was: Before this commit we would have to write this kind of stuff as a string

    SlashCmdList.PFCASTFOCUS( 'function() CastspellByName("Renew", 1); end' )

    this was both 10x slower and was extremely cumbersome and error-prone for the user if he wanted to pass some variable-state inside the string-func-callback.
@dsidirop dsidirop marked this pull request as draft February 15, 2026 20:17
@dsidirop dsidirop closed this Feb 15, 2026
@dsidirop
Copy link
Contributor Author

This PR was based on the wrong branch. Closed it and re-opened it using the correct branch in #1610 so have a look at that one.

@dsidirop dsidirop deleted the dsidirop/PF-0029-optimize-castfocus-using-superwow branch February 15, 2026 21:24
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.

2 participants