The old replace all string function is so very slow when you have over 1000 chars to replace.
So I decide to make this function to replace all string with faster algorithm.
I make my function in DLL for easy to use with ASM or C at your choice (ntlib.dll).
In my DLL not only content replace all string function, it also content some of my favorite's function that I written in assembly.
I make 2 samples, once in C (M$ Visual C++) and once in ASM (MASM) to help you easy to understand my function.

Have fun

Posted on 2003-03-08 05:20:57 by nhnpresario
Posted on 2003-03-09 06:22:10 by nhnpresario
As you can see, my function can replace 25088 chars in 1s with my P3 800 Mhz, 256 MB RAM (PC 800)
Posted on 2003-03-09 06:22:56 by nhnpresario

Nice work! :alright: Your application can be usefull to manipulate large
asm source files.


Posted on 2003-03-09 06:31:29 by Vortex
That's right!
When we have a large asm file, if we want to change variable name or change function name, old algorithm so very slow.
Posted on 2003-03-12 00:35:22 by nhnpresario
The problem with notepad is not the algorithm but the fact that it scrolls the editbox to the text before replacing it to show you what's happening. *That's* slow. It's nice to have an alternative notepad that doesn't do this, although I usually use a 'real' editor for programming :).

Posted on 2003-03-12 01:32:24 by Thomas
Hi nhnpresario,

Very nice work and well documented.
This example is really useful for people that are interested in learning or changing from c to masm.

Thank you
Posted on 2003-03-12 11:08:39 by ipadilla
Nice... a fresh notepad-clone.. :) But just for the record.. Wordpad does have a very
fast replace algo.. ;)
Posted on 2003-03-12 14:05:08 by natas
Shouldnt this thread be moved to the algos and source code forum
Posted on 2003-03-14 00:50:01 by clippy

"The old replace all string function is so very slow..."
Your search string algo is very slow too, and you can replace it with Boyer-Moore
algo for example

Posted on 2003-03-14 20:24:31 by lingo12
;) He he
I don't think so.
I tested my function in 20 MB text with no problem(s).
As you know, my function with Whole Word specific (that still not presented in M$ Notepad) and Match Case specific but it can replace all or find or replace so fast.
I found Boyer-Moore in MASM package but I still not understand about his idea so I decided to make my own.
Now I make some change in my lib to optimize it may be faster (I think) by changed CharLowerA API to a customer function.
Have fun!:alright:
Best regards.
Posted on 2003-03-15 02:27:01 by nhnpresario