This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Precompiler headers
- To: Wolfgang dot Bangerth at IWR dot Uni-Heidelberg dot De
- Subject: Re: Precompiler headers
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Fri, 14 Jan 2000 09:56:31 +0100
- CC: oliva at lsd dot ic dot unicamp dot br, gcc at gcc dot gnu dot org
- References: <Pine.SOL.4.10.10001140825090.24047-100000@eros>
> In my understanding, 'export'ed templates would not be inlined, not?
> I always thought 'export' was about the same as -frepo. However, all
> the STL stuff would really suffer if functions were not inlined any
> more.
I think this is not true. Not *all* the STL stuff. I've included two
functions below, one from stl_algo.h, the other from fstream.tcc of
libstdc++ v3. I don't think there is that much lossage if those
functions are not inlined.
Nobody says that *all* functions would have to be exported, only the
large ones. These also happen to be the functions that take a lot of
time for parsing and analysis, and which then get rarely invoked.
Regards,
Martin
template <class _InputIter, class _RandomAccessIter, class _Compare,
class _Distance, class _Tp>
_RandomAccessIter __partial_sort_copy(_InputIter __first,
_InputIter __last,
_RandomAccessIter __result_first,
_RandomAccessIter __result_last,
_Compare __comp, _Distance*, _Tp*) {
if (__result_first == __result_last) return __result_last;
_RandomAccessIter __result_real_last = __result_first;
while(__first != __last && __result_real_last != __result_last) {
*__result_real_last = *__first;
++__result_real_last;
++__first;
}
make_heap(__result_first, __result_real_last, __comp);
while (__first != __last) {
if (__comp(*__first, *__result_first))
__adjust_heap(__result_first, _Distance(0),
_Distance(__result_real_last - __result_first),
_Tp(*__first),
__comp);
++__first;
}
sort_heap(__result_first, __result_real_last, __comp);
return __result_real_last;
}
template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::underflow()
{
int_type __retval = traits_type::eof();
bool __testpos = _M_in_cur && _M_in_cur >= _M_buf + _M_buf_size;
bool __testinit = _M_is_indeterminate();
bool __testinout = _M_mode & ios_base::in && _M_mode & ios_base::out;
bool __testin = _M_mode & ios_base::in;
if (__testin)
{
// __testpos -> ! __testinit
if (__testinout && __testpos)
{
// Write out buffer, then underflow.
this->overflow();
_M_set_indeterminate();
}
if (__testinit || __testpos)
{
// Part one: (Re)fill external buf (_M_file->_IO_*) from
// external byte sequence (whatever physical byte sink or
// FILE actually is.)
streamsize __size = _M_buf_size;
char __conv_buf[__size];
__size = _M_file->xsgetn(__conv_buf, __size);
// Part two: (Re)fill internal buf contents from external buf.
if (0 < __size && __size <= static_cast<streamsize>(_M_buf_size))
{
_M_set_determinate(__size);
char* __conv_cur = __conv_buf;
_M_state_beg = _M_state_cur;
__res_type __r = _M_fcvt->in(_M_state_cur,
__conv_buf,
__conv_buf + __size,
const_cast<const char*&>(__conv_cur),
_M_in_beg, _M_in_end, _M_in_cur);
if (__r == codecvt_base::partial)
{
// XXX Retry with larger _M_buf size.
}
// Set pointers to internal and external buffers
// correctly. . .
if (__r != codecvt_base::error)
{
if (_M_mode & ios_base::out)
_M_out_cur = _M_in_cur;
__retval = traits_type::to_int_type(*_M_in_cur);
}
}
// Part three: Sync the current internal buffer position
// with the (now overshot) external buffer position.
if (__testinout && 0 < __size
&& __size <= static_cast<streamsize>(_M_buf_size))
{
off_type __sync_off = 0 - __size;
off_type __fail = _M_file->seekoff(__sync_off,
ios_base::cur, _M_mode);
if (__fail != __sync_off)
{
// XXX Do error checking.
}
}
}
}
_M_last_overflowed = false;
return __retval;
}