Quote:
Originally Posted by Nightfox
ok, I thought I'd put this little bit of code (for certain definitions of little) up for those more skilled with coding to look at and see if they could find a better way of doing everything so that it would not be quite as intensive.
Note that this is rather ugly so those of you who are code-aphobic, you may want to look away.
As it stands, I'm thinking I may need to create separate specials to run the code for the sake of space and timing, but that could end up drastically increasing the number of foreach statements and therefore processing requirements.
|
My confusion in going over this is the way you structured the foreach loops:
Code:
foreach pick on hero where (field[cIndex].value < 20)
If you are going to do a foreach loop then at least limit the context down by component sets. This loop here goes after every PICK on the hero then tries to subset by a field that may or may not even exist on the picks list of fields.
Limit the foreach scope like this:
Code:
foreach pick in hero from BaseClHelp where "TagGroup.Tag"
or
foreach pick in hero from BaseClHelp
Always better to use a tag then any field for searching. HL is optimized to deal with Tags not so much with fields. By saying "from BaseClHelp" we are limiting HL down to just the Class Helper Picks on the hero which will be ALLOT smaller subset of Picks to deal with then every Pick.
Please note I can't remember if BaseClHelp is correct for d20 as I am not near HL. You can see which "Components" make up a Pick by looking at its tags and the '
component.?' group section.