1

I'm trying to combine array objects to strings so that I get many combinations of results.(3000+) However, this following code does work, but it is insufficient/slow. It also tends to freeze.

I have tried with for loops as well but i get the same time taken.

Is there another way to make this more efficient? I have looked a bit at set interval, but made no progress there.

$.each(page_name, function(i, p) {
    $.each(extensions, function(ii, e) {
        $.each(query, function(iii, q) {
            var data = p + "." + e + "?" + q;
            dorks.push(data);
            $('#result').append(data + '\n');
            $("#amt").text(dorks.length);
        });
    });
});
BlitZz
  • 132
  • 1
  • 14
  • can you some part of `page_name` and `extensions` contents? – RomanPerekhrest Dec 18 '16 at 00:18
  • don't append in each iteration ... create the content and only insert it once when loop is done. Same with the length...insert it once when you have a final length – charlietfl Dec 18 '16 at 00:19
  • Also not clear where you call this from. Is it only done once or numerous times? – charlietfl Dec 18 '16 at 00:20
  • @RomanPerekhrest the page_name, extensions and query are arrays ["a","b","c"] etc – BlitZz Dec 18 '16 at 00:21
  • What is expected result? – guest271314 Dec 18 '16 at 00:23
  • @charlietfl Thank you, It makes sense now that you say it. I will do it your way! :) What do you mean, "not clear"? – BlitZz Dec 18 '16 at 00:23
  • meaning are you doing this process numerous times in a short period? Or just once in a while when data is requested? – charlietfl Dec 18 '16 at 00:26
  • @guest271314 ElementCollection.php?storeid= ElementCollection.php?id= ElementCollection.php?product= ElementCollection.php?cartID= ElementCollection.php?bookid= example_element_group.php?storeid= example_element_group.php?id= example_element_group.php?product= example_element_group.php?cartID= .... – BlitZz Dec 18 '16 at 00:27
  • @BlitZz The text of comment does not clarify what the input arrays are or the expected result. See http://stackoverflow.com/help/mcve, http://stackoverflow.com/help/how-to-ask . _"this following code does work, but it is insufficient/slow. It also tends to freeze."_ Can you reproduce the current result at stacksnippets, jsfiddle http://jsfiddle.net, or plnkr http://plnkr.co? Presently, not clear, from perspective here, what you are asking? – guest271314 Dec 18 '16 at 00:28
  • @charlietfl Im calling this process once to generate the output combined from 3 different arrays. so example output: 1.1?=1 - 1.1?=2 - 1.1?=3 - 2.1?=1, 2.1?=2 – BlitZz Dec 18 '16 at 00:30

0 Answers0