Thread Tools Display Modes
07-26-13, 09:42 PM   #21
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Rainrider View Post
Code:
fontString:SetText(format(t[3], value/t[2]):gsub("%.", " , "))
(this would also add spaces before and after the decimal seperator)
Using string functions as metamethods is the slowest possible way to use them. Do this instead:

Code:
fontString:SetText(gsub(format(t[3], value / t[2]), "%.", " , "))
Also, if you're going to be using format directly instead of letting SetFormattedText handle it, you should upvalue format, since TextStatusBar_UpdateTextStringWithValues can be called quite often. Add this at the top of your file, outside of any function:

Code:
local format, gsub = format, gsub
This creates local references to these global functions, so when you call format later, your code is using the faster local reference, instead of a slower global lookup.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
07-27-13, 06:20 AM   #22
laukond
A Black Drake
Join Date: Dec 2011
Posts: 87
It does not update it that way.
  Reply With Quote
07-27-13, 06:22 AM   #23
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Originally Posted by Phanx View Post
Using string functions as metamethods is the slowest possible way to use them. Do this instead:

Code:
fontString:SetText(gsub(format(t[3], value / t[2]), "%.", " , "))
Omg, I failed twice the same topic in the same thread
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » 3 Questions

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off