mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-08 10:11:21 +00:00
fix slowness in lyxsum
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_1_6@2091 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5df0b887fb
commit
947777dfc0
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
2001-05-30 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* configure.in:
|
||||
* src/support/lyxsum.C (sum): use istreambuf_iterator when
|
||||
available.
|
||||
|
||||
2001-05-29 Lars Gullik Bjønnes <larsbj@birdstep.com>
|
||||
|
||||
* src/support/lyxsum.C (sum): don't use sstream anymore, use
|
||||
istream_iterator directly instead.
|
||||
|
||||
2001-05-23 Angus Leeming <a.leeming@ic.ac.uk>
|
||||
|
||||
* src/frontends/xforms/FormInset.C (createInset): fixed bug
|
||||
|
@ -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)
|
||||
|
@ -16,8 +16,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "Lsstream.h"
|
||||
#include <iterator>
|
||||
|
||||
#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<char> beg(ifs);
|
||||
std::istreambuf_iterator<char> end;
|
||||
#else
|
||||
// than this.
|
||||
ifs.unsetf(std::ios::skipws);
|
||||
std::istream_iterator<char> beg(ifs);
|
||||
std::istream_iterator<char> end;
|
||||
#endif
|
||||
|
||||
return do_crc(beg, end);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user