]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
MaplistMethod_Shuffle: use sprintf to hopefully increase performance a bit more terencehill/MaplistMethod_Shuffle_optimization
authorterencehill <piuntn@gmail.com>
Fri, 2 Jun 2023 17:28:15 +0000 (19:28 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 2 Jun 2023 17:28:15 +0000 (19:28 +0200)
qcsrc/server/intermission.qc

index 360c15c94f583f008ee161cf40a0aa71b6c86a5e..000ae0f8649aac7d19b5b5c49040e1df9937a6d9 100644 (file)
@@ -234,16 +234,16 @@ float MaplistMethod_Shuffle(float exponent) // more clever shuffling
                newlist = "";
                for(j = 1; j < insertpos; )                 // i == 1: no loop, will be inserted as first; however, i == 1 has been excluded above
                {
-                       if (j + 2 < insertpos)
-                               newlist = strcat(newlist, " ", argv(j++), " ", argv(j++), " ", argv(j++));
+                       if (j + 4 < insertpos)
+                               newlist = sprintf("%s %s %s %s %s %s", newlist, argv(j++), argv(j++), argv(j++), argv(j++), argv(j++));
                        else
                                newlist = strcat(newlist, " ", argv(j++));
                }
                newlist = strcat(newlist, " ", argv(0));       // now insert the just selected map
                for(j = insertpos; j < Map_Count; )         // i == Map_Count: no loop, has just been inserted as last
                {
-                       if (j + 2 < Map_Count)
-                               newlist = strcat(newlist, " ", argv(j++), " ", argv(j++), " ", argv(j++));
+                       if (j + 4 < Map_Count)
+                               newlist = sprintf("%s %s %s %s %s %s", newlist, argv(j++), argv(j++), argv(j++), argv(j++), argv(j++));
                        else
                                newlist = strcat(newlist, " ", argv(j++));
                }