"I've been writing C for quite some time, but I never followed good conventions I'm afraid, and I never payed much attention to the optimization tricks of the higher C programmers. Sure, I use const when I can, I use the pointer methods for manual string copying, I even use register for all the good that does with modern compilers, but now, I'm trying to write a C-string handling library for personal use, but I need speed, and I really don't want to use inline ASM. So, I am wondering, what would other Soylenters do to write efficient, pure, standards-compliant C?"
Sure, I use const when I can, I use the pointer methods for manual string copying, I even use register for all the good that does with modern compilers, but now, I'm trying to write a C-string handling library for personal use
The above gives no indication that you understand what you are currently doing, let alone what you intend to do.My advice would be to learn the basics before jumping into the pilot's cabin.Once you know what you are doing with C, google yourself a good string algorithm that matches your intended use patterns and implement that in non-clever C.Once that is done, take the code using your string library and profile it. If it's good enough then just use it as is.Once you identify the bottleneck is say the raw character copy, you google again for the fastest way of moving stuff around. You replace your old copying code and then see if it works.If you start out looking for fast copying hacks, or improvising with algorithms, you'll end up with a slow unusable piece of crap.Intended use is the most important part!You can see people here raving about immutable strings or whatever, but "appending" stuff to a simple immutable string object can easily bring a system down. Usually, seemingly dumb algorithms have their strong points as well. It's not "What were System.String or strcat(3) designers smoking?" but "What was I smoking when I used that for my log storage?".