|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
String vs. Stringbuilder speed parsing questioHi everyone,
Can you help me please? Say you have hashtable of about 500 key/value pairs. This hashtable has to parse a word. If the word matches the key the then said word must be replaced by the value. My question is though - would parsing occur faster if the word is input as a type string or a type stringbuilder? Do you see my point? Would appreciate any comments/experiences/suggestions that anyone has on this one... Al. Your best bet is to test. StringBuilder are faster if you have significants
processing to do on a string and/or if those strings are big. Here I don't really see what you mean (do you mean you would use stringbuilders as keys instead of strings hoping it would speed up data retrieval, if yes IMO you won't see any difference). For a start you can try to time your code to see what is the slowest part... -- Show quoteHide quotePatrice <almu***@altavista.com> a écrit dans le message de news:1139315964.067015.254030@g44g2000cwa.googlegroups.com... > Hi everyone, > > > Can you help me please? Say you have hashtable of about 500 key/value > pairs. This hashtable has to parse a word. If the word matches the key > the then said word must be replaced by the value. > My question is though - would parsing occur faster if the word is > input as a type string or a type stringbuilder? Do you see my point? > Would appreciate any comments/experiences/suggestions that anyone has > on this one... > > Al. > Hi Al,
The hash table is fine with String. The StringBuilder is mostly used to build strings concatenating small strings many times or replacing/inserting text inside a large string, so you have to see if this fits in your problem, which surely does for replacing the words by the new ones in the paragraph that you want to process. -- Show quoteHide quoteBest regards, Carlos J. Quintero MZ-Tools: Productivity add-ins for Visual Studio You can code, design and document much faster: http://www.mztools.com <almu***@altavista.com> escribió en el mensaje news:1139315964.067015.254030@g44g2000cwa.googlegroups.com... > Hi everyone, > > > Can you help me please? Say you have hashtable of about 500 key/value > pairs. This hashtable has to parse a word. If the word matches the key > the then said word must be replaced by the value. > My question is though - would parsing occur faster if the word is > input as a type string or a type stringbuilder? Do you see my point? > Would appreciate any comments/experiences/suggestions that anyone has > on this one... > > Al. > Al,
A string is an immutable string of characters A stringbuilder is a muttable string of characters. Therefore it needs at least instructions to set it to an immutable string of charaters that you probably need. (ToString) Cor Patrice, Carlos & Cor - thank you all for your comments.
Cheers, Al.
ADO.net + MS Access = performance issues
VB.NET Structures and Union Help. how to group similar events? 2nd Post: Problem adding events to controls created at run-time KeyUp + KeyDown Event Handler Multiple threads using a shared printer resource Problems with ByRef parameters Copying files across network System.IO.FileSystemWatcher is missing alot of files. continue debugging without interrupting |
|||||||||||||||||||||||