This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/45574] cin.getline() is extremely slow
- From: "tstarling at wikimedia dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 Sep 2010 15:25:42 -0000
- Subject: [Bug libstdc++/45574] cin.getline() is extremely slow
- References: <bug-45574-19663@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #24 from tstarling at wikimedia dot org 2010-09-10 15:25 -------
Created an attachment (id=21766)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21766&action=view)
dynamic_cast<> hack
The attached patch uses a dynamic_cast<> hack to avoid the need to break the
ABI. I added *_unlocked functions to cstdio, I'm not sure if this is necessary,
but it's easy enough to remove that part if not. I also added some
lightly-tested autoconf stuff. I'm an autoconf newbie so that part should
probably be reviewed carefully.
stdio_sync_filebuf<wchar_t>::_M_getline() is currently unreachable, since I
only edited basic_istream<char>::getline() and not
basic_istream<wchar_t>::getline(). It would be easy enough to fix that. I
haven't used getwc_unlocked() because it's a GNU extension, POSIX only has
non-wide unlocked I/O.
The timings for 1M lines with 500 bytes per line, user time only, are:
Old library: 26.7s
New library: 1.65s
fgets: 0.280s
So it's better, but not perfect.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45574