diff --git a/ChangeLog b/ChangeLog index 7802866a25..849f5142a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-05-30 Lars Gullik Bjønnes + + * configure.in: + * src/support/lyxsum.C (sum): use istreambuf_iterator when + available. + +2001-05-29 Lars Gullik Bjønnes + + * src/support/lyxsum.C (sum): don't use sstream anymore, use + istream_iterator directly instead. + 2001-05-23 Angus Leeming * src/frontends/xforms/FormInset.C (createInset): fixed bug diff --git a/configure.in b/configure.in index ee988380a7..0655ed4241 100644 --- a/configure.in +++ b/configure.in @@ -253,6 +253,7 @@ fi AC_CHECK_FUNCS(snprintf vsnprintf) LYX_CHECK_DECL(snprintf, stdio.h) LYX_CHECK_DECL(vsnprintf, stdio.h) +LYX_CHECK_DECL(istreambuf_iterator, iterator) AC_CHECK_FUNCS(memmove memset strchr putenv setenv mkfifo \ mkstemp mktemp) diff --git a/src/support/lyxsum.C b/src/support/lyxsum.C index 8980a3f8ae..d9ba88db08 100644 --- a/src/support/lyxsum.C +++ b/src/support/lyxsum.C @@ -16,8 +16,7 @@ #include #include - -#include "Lsstream.h" +#include #include "support/lyxlib.h" @@ -108,14 +107,20 @@ unsigned long do_crc(InputIterator first, InputIterator last) // And this would be the file interface. unsigned long lyx::sum(string const & file) { - ifstream ifs(file.c_str()); + std::ifstream ifs(file.c_str()); if (!ifs) return 0; - ifs.unsetf(ios::skipws); - ostringstream ostr; - ostr << ifs.rdbuf(); - // The .c_str() is here in case we use our lyxstring class - // instead of standard string. - string w = ostr.str().c_str(); - return do_crc(w.begin(), w.end()); + +#ifdef HAVE_DECL_ISTREAMBUF_ITERATOR + // This is a lot faster... + std::istreambuf_iterator beg(ifs); + std::istreambuf_iterator end; +#else + // than this. + ifs.unsetf(std::ios::skipws); + std::istream_iterator beg(ifs); + std::istream_iterator end; +#endif + + return do_crc(beg, end); }