Mercurial > hg > forks > multipaint-js
changeset 193:7a9dc175ece5
Use dst = src.slice(0) instead of Processing arrayCopy(src, dst) for cloning arrays. Should be faster, but if not, this can be reverted later.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 23 Aug 2018 18:01:16 +0300 |
parents | 0dec83e42d90 |
children | d67a79d6e11c |
files | buffers.pde |
diffstat | 1 files changed, 16 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/buffers.pde Thu Aug 23 17:27:50 2018 +0300 +++ b/buffers.pde Thu Aug 23 18:01:16 2018 +0300 @@ -23,9 +23,9 @@ void store_undo() { if (g_spare) - arrayCopy(g_map, g_undobs[g_uindex[g_spare]]); + g_undobs[g_uindex[g_spare]] = g_map.slice(0); else - arrayCopy(g_map, g_undob[g_uindex[g_spare]]); + g_undob[g_uindex[g_spare]] = g_map.slice(0); g_uindex[g_spare]++; if (g_uindex[g_spare] > UNDOSTEPS) @@ -50,18 +50,18 @@ return; if (g_spare) - arrayCopy(g_map, g_undobs[g_uindex[g_spare]]); + g_undobs[g_uindex[g_spare]] = g_map.slice(0); else - arrayCopy(g_map, g_undob[g_uindex[g_spare]]); + g_undob[g_uindex[g_spare]] = g_map.slice(0); g_uindex[g_spare]--; if (g_uindex[g_spare] < 0) g_uindex[g_spare] = UNDOSTEPS; if (g_spare) - arrayCopy(g_undobs[g_uindex[g_spare]], g_map); + g_map = g_undobs[g_uindex[g_spare]].slice(0); else - arrayCopy(g_undob[g_uindex[g_spare]], g_map); + g_map = g_undob[g_uindex[g_spare]].slice(0); refreshpalette(); ustats(); @@ -78,9 +78,9 @@ g_uindex[g_spare] = 0; if (g_spare) - arrayCopy(g_undobs[g_uindex[g_spare]], g_map); + g_map = g_undobs[g_uindex[g_spare]].slice(0); else - arrayCopy(g_undob[g_uindex[g_spare]], g_map); + g_map = g_undob[g_uindex[g_spare]].slice(0); refreshpalette(); ustats(); @@ -89,9 +89,9 @@ void spare() //dpaint style spare page { - arrayCopy(g_sparepage, g_swappage); - arrayCopy(g_map, g_sparepage); - arrayCopy(g_swappage, g_map); + g_swappage = g_sparepage.slice(0); + g_sparepage = g_map.slice(0); + g_map = g_swappage.slice(0); mpSetTitle(g_spare ? sfilename : filename); @@ -110,10 +110,10 @@ switch (mode) { case 0: - arrayCopy(g_map, g_rmap); + g_rmap = g_map.slice(0); break; case 1: - arrayCopy(g_rmap, g_map); + g_map = g_rmap.slice(0); for (int i = 0; i < 1024; i++) { if (g_remdo[i] == 1) @@ -124,13 +124,13 @@ } break; case 2: - arrayCopy(g_map, g_brush); + g_brush = g_map.slice(0); break; case 3: - arrayCopy(g_map, g_sparepage); + g_sparepage = g_map.slice(0); break; case 4: - arrayCopy(g_sparepage, g_mapm); + g_mapm = g_sparepage.slice(0); break; } }