From 459f91af241e25e7181646f1102d86c5f0f3d6f6 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 7 Feb 2006 09:02:08 +0000 Subject: [PATCH] optimized this further --- amxmodx/string.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/amxmodx/string.cpp b/amxmodx/string.cpp index 29145ee6..b1936572 100755 --- a/amxmodx/string.cpp +++ b/amxmodx/string.cpp @@ -177,7 +177,7 @@ static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */ cell len = params[2]; cell *what = get_amxaddr(amx, params[3]); cell *with = get_amxaddr(amx, params[4]); - cell *origtext = text; + cell *textptr = text; int withLen = amxstring_len(with); int whatLen = amxstring_len(what); @@ -207,13 +207,9 @@ static cell AMX_NATIVE_CALL replace(AMX *amx, cell *params) /* 4 param */ { cell *saveptr = text + whatLen; cell restlen = textLen - (browsed + whatLen); - cell amx_addr, *phys_addr; - amx_Allot(amx, restlen + 1, &amx_addr, &phys_addr); - memcpy(phys_addr, saveptr, (restlen + 1) * sizeof(cell)); + textptr = text + withLen; + memmove(textptr, saveptr, (restlen + 1) * sizeof(cell)); memcpy(text, with, withLen * sizeof(cell)); - text += withLen; - memcpy(text, phys_addr, (restlen + 1) * sizeof(cell)); - amx_Release(amx, amx_addr); return (textLen - whatLen + withLen); } }