Jump to content
  • 0

Help Search value Improvement


XEKEX

Question

       I wrote this bloc of code in my script and I need help for improving it bc performance and speed are trash in this loop I also have 7K values in ListOfPointers 
the script is basically goes to class name > field> get all the pointers of its value (ListOfPointers) convert the values to string and check if it match the public const string

Quote

 

  ListOfPointers= gg.getResults(gg.getResultsCount())

          listfound ={}

          ------------------------------------------------

          for index,value in pairs(ListOfPointers) do

            Test = {}

            Test[1] = ListOfPointers[index] ----------------------------> take the 1er pointer then 2ed etc until the last pointer value

          gg.loadResults(Test)

          Test = gg.getResults(gg.getResultsCount())

          Test = gg.getResults(1)

         -------------------------------------------------------> the value here represent the lengh of the offset i'm going to go through

              for i,v in pairs(Test) do

                  Test[i].address = Test[i].address + 8

              end

----------------------------------------------------------------->
 

              gg.loadResults(Test)

              Test=gg.getResults(gg.getResultsCount())

 

              for i,v in pairs(Test) do

                Len = Test[i].value

              end

------------------------------------------------------------------------------------------------- here check if the lengh is correct / evade bugs
 

          if Len < 3 or Len > 97 then index = index + 1 else

 

              P = NL(Len)/2

              for i,v in pairs(Test) do

                  Test[i].address = Test[i].address +4

              end

 

             

              gg.loadResults(Test)

          Test=gg.getResults(gg.getResultsCount())

          checker = {}

---------------------------------------------------------------------------> here i add every value in a table until the last offest

          for f = 1, P do

 

              for i,v in pairs(Test) do

                  Test[i].address = Test[i].address +4

                  checker[f] = Test[i].value

              end

 

              gg.loadResults(Test)

              Test=gg.getResults(gg.getResultsCount())

 

          end

-------------------------------------------------------------------------------------->  merg(checker) convert values into string and check if the values match the string (match the string in the table)

          listfound[index] = merg(checker)

          gg.toast(tostring(listfound[index])..' '..tostring(#Item-index)..' Remain')

    end

  end

 

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Use "getValues" instead of "loadResults" followed with "getResults". And more importantly, instead of calling the function for each value, construct table with all values and call the function once for that table.

Example of how it should not be done: 

local results = gg.getResults(gg.getResultsCount())
for _, result in ipairs(results) do
  local checkedValue = {{address = result.address + 8, flags = result.flags}}
  checkedValue = gg.getValues(checkedValue)
  local value = checkedValue[1].value
  -- some further processing according to value
end

Example of what should be done instead: 

local results = gg.getResults(gg.getResultsCount())
local checkedValues = {}
for index, result in ipairs(results) do
  checkedValues[index] = {address = result.address + 8, flags = result.flags}
end
checkedValues = gg.getValues(checkedValues)
for i, v in ipairs(checkedValues) do
  local value = v.value
  -- some further processing according to value
end
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.