On Tue, Nov 27, 2007 at 08:54:07PM +0100, Andre Poenitz wrote:
> 
> > bash ../development/tools/count_lines_of_included_code.sh debug.h
> debug.h                                 : 30091
> 
> ;-(

Using something "handcrafted" along the lines of

        struct LyXErr {
                bool debugging(Debug::type t = Debug::ANY) const;
                void endl();
        };

        LyXErr & operator<<(LyXErr &, const char *);
        LyXErr & operator<<(LyXErr &, char);
        LyXErr & operator<<(LyXErr &, int);
        LyXErr & operator<<(LyXErr &, double);
        LyXErr & operator<<(LyXErr &, std::string const &);
        LyXErr & operator<<(LyXErr &, docstring const &);
        LyXErr & operator<<(LyXErr &, support::FileName const &);
        LyXErr & operator<<(LyXErr &, std::ostream &(*)(std::ostream &));
        [... possibly a few more added, no #include, though]

        extern LyXErr lyxerr;

        #define LYXERR(type, msg) \
                do { \
                        if (!lyx::lyxerr.debugging(type)) {} \
                        else { lyx::lyxerr << msg; lyxerr.endl(); } \
                } while (0)


instead of the current std::ostream/boost::nullstream based solution
would cut down total compiled lines from currently 17.9 Mio to 17.0
Mio, i.e. reduce compilation effort by almost exactly 5%.

Note that this would also allow us to "magically" pipe "unmodified"
std::strings and docstrings into the same "stream" and therefore
simplify the calling code by removing the need for 170 (rough
guesstimate by  grep -R -i -A2 lyxerr | grep to_utf8 | grep -v svn | wc)
'to_utf8' calls in the code.

Sounds interesting?

Andre'

Reply via email to