|
From: Neal R. <ne...@ri...> - 2003-02-02 00:40:08
|
> Greetings Neal, > > That is a very sensible change, but I have two questions. > First, in the change > - if (s.length() > 0) > - copy(s.Data, s.length(), s.length()); > + if (slen != 0) > + copy(s.Data, slen, slen); > was there a reason to replace the '>' by '!='? It is defensive > programming not to copy negative-length strings. Hmm. I'll change that back. I definetly meant to keep it as ">". I was cut and pasting code from an older snapshot where I made the changes. Good spot. > Second, do you know why gprof sees the calls to length() at all? > Shouldn't an inline function be optimised out? If so, the > optimisation becomes removing a few pointer dereferences (which > should also be optimised out by a sensible compiler). That said, I > agree that it is tidier not to rely on an optimising compiler. At least according to my examinations so far, very few of our inline functions end upgetting inlined. I've done a fair bit of work with gprof and looking at what functions are actually inlined in the assembly. At least with -O2 I'm not seeing some of them making it. I'll look up some more information on inlining. It's only a suggestion to the compiler and we need to be checking the assembly (DDD is a nice GUI debugger that allows assembly viewing during debugging) to see when it actually works. My next set of changes are going to be enhancements to WordDB, & WordKey. The inlines in WordDB aren't making it, and I found a way to eliminate many function calls in WordKey. There are also a bunch of places where functions are called in the comparison part of for loops. We need to eliminate these. I need to get more familiar with how gcc does some of these optimizations.. but at the same time I'm inclined not to rely on it too much. FYI there is a nice article on how Intel's new linux compiler does some of its optimizations in the new issue of Linux Journal. Question: is it me or are the last few issues of Dr Dobbs and Linux Journal looking very 'thin'? Neal Richter Knowledgebase Developer RightNow Technologies, Inc. Customer Service for Every Web Site Office: 406-522-1485 |