This is an optimization which produces improved launching time. There should be no functionality change. Clients should see no ABI differences.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@177443 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -41,7 +41,7 @@ public:
|
|||||||
typedef typename traits_type::off_type off_type;
|
typedef typename traits_type::off_type off_type;
|
||||||
typedef typename traits_type::state_type state_type;
|
typedef typename traits_type::state_type state_type;
|
||||||
|
|
||||||
explicit __stdinbuf(FILE* __fp);
|
__stdinbuf(FILE* __fp, state_type* __st);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int_type underflow();
|
virtual int_type underflow();
|
||||||
@@ -53,7 +53,7 @@ private:
|
|||||||
|
|
||||||
FILE* __file_;
|
FILE* __file_;
|
||||||
const codecvt<char_type, char, state_type>* __cv_;
|
const codecvt<char_type, char, state_type>* __cv_;
|
||||||
state_type __st_;
|
state_type* __st_;
|
||||||
int __encoding_;
|
int __encoding_;
|
||||||
bool __always_noconv_;
|
bool __always_noconv_;
|
||||||
|
|
||||||
@@ -64,9 +64,9 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class _CharT>
|
template <class _CharT>
|
||||||
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp)
|
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
|
||||||
: __file_(__fp),
|
: __file_(__fp),
|
||||||
__st_()
|
__st_(__st)
|
||||||
{
|
{
|
||||||
imbue(this->getloc());
|
imbue(this->getloc());
|
||||||
}
|
}
|
||||||
@@ -119,15 +119,15 @@ __stdinbuf<_CharT>::__getchar(bool __consume)
|
|||||||
codecvt_base::result __r;
|
codecvt_base::result __r;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
state_type __sv_st = __st_;
|
state_type __sv_st = *__st_;
|
||||||
__r = __cv_->in(__st_, __extbuf, __extbuf + __nread, __enxt,
|
__r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt,
|
||||||
&__1buf, &__1buf + 1, __inxt);
|
&__1buf, &__1buf + 1, __inxt);
|
||||||
switch (__r)
|
switch (__r)
|
||||||
{
|
{
|
||||||
case _VSTD::codecvt_base::ok:
|
case _VSTD::codecvt_base::ok:
|
||||||
break;
|
break;
|
||||||
case codecvt_base::partial:
|
case codecvt_base::partial:
|
||||||
__st_ = __sv_st;
|
*__st_ = __sv_st;
|
||||||
if (__nread == sizeof(__extbuf))
|
if (__nread == sizeof(__extbuf))
|
||||||
return traits_type::eof();
|
return traits_type::eof();
|
||||||
{
|
{
|
||||||
@@ -167,7 +167,7 @@ __stdinbuf<_CharT>::pbackfail(int_type __c)
|
|||||||
char* __enxt;
|
char* __enxt;
|
||||||
const char_type __ci = traits_type::to_char_type(__c);
|
const char_type __ci = traits_type::to_char_type(__c);
|
||||||
const char_type* __inxt;
|
const char_type* __inxt;
|
||||||
switch (__cv_->out(__st_, &__ci, &__ci + 1, __inxt,
|
switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
|
||||||
__extbuf, __extbuf + sizeof(__extbuf), __enxt))
|
__extbuf, __extbuf + sizeof(__extbuf), __enxt))
|
||||||
{
|
{
|
||||||
case _VSTD::codecvt_base::ok:
|
case _VSTD::codecvt_base::ok:
|
||||||
@@ -200,7 +200,7 @@ public:
|
|||||||
typedef typename traits_type::off_type off_type;
|
typedef typename traits_type::off_type off_type;
|
||||||
typedef typename traits_type::state_type state_type;
|
typedef typename traits_type::state_type state_type;
|
||||||
|
|
||||||
explicit __stdoutbuf(FILE* __fp);
|
__stdoutbuf(FILE* __fp, state_type* __st);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int_type overflow (int_type __c = traits_type::eof());
|
virtual int_type overflow (int_type __c = traits_type::eof());
|
||||||
@@ -210,7 +210,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
FILE* __file_;
|
FILE* __file_;
|
||||||
const codecvt<char_type, char, state_type>* __cv_;
|
const codecvt<char_type, char, state_type>* __cv_;
|
||||||
state_type __st_;
|
state_type* __st_;
|
||||||
bool __always_noconv_;
|
bool __always_noconv_;
|
||||||
|
|
||||||
__stdoutbuf(const __stdoutbuf&);
|
__stdoutbuf(const __stdoutbuf&);
|
||||||
@@ -218,10 +218,10 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <class _CharT>
|
template <class _CharT>
|
||||||
__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp)
|
__stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st)
|
||||||
: __file_(__fp),
|
: __file_(__fp),
|
||||||
__cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
|
__cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
|
||||||
__st_(),
|
__st_(__st),
|
||||||
__always_noconv_(__cv_->always_noconv())
|
__always_noconv_(__cv_->always_noconv())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ __stdoutbuf<_CharT>::overflow(int_type __c)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
const char_type* __e;
|
const char_type* __e;
|
||||||
__r = __cv_->out(__st_, this->pbase(), this->pptr(), __e,
|
__r = __cv_->out(*__st_, this->pbase(), this->pptr(), __e,
|
||||||
__extbuf,
|
__extbuf,
|
||||||
__extbuf + sizeof(__extbuf),
|
__extbuf + sizeof(__extbuf),
|
||||||
__extbe);
|
__extbe);
|
||||||
@@ -289,7 +289,7 @@ __stdoutbuf<_CharT>::sync()
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
char* __extbe;
|
char* __extbe;
|
||||||
__r = __cv_->unshift(__st_, __extbuf,
|
__r = __cv_->unshift(*__st_, __extbuf,
|
||||||
__extbuf + sizeof(__extbuf),
|
__extbuf + sizeof(__extbuf),
|
||||||
__extbe);
|
__extbe);
|
||||||
size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
|
size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||||
|
|
||||||
|
static mbstate_t state_types[6] = {};
|
||||||
|
|
||||||
_ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin [sizeof(__stdinbuf <char>)];
|
_ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin [sizeof(__stdinbuf <char>)];
|
||||||
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
|
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
|
||||||
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
|
_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
|
||||||
@@ -33,17 +35,17 @@ ios_base::Init __start_std_streams;
|
|||||||
|
|
||||||
ios_base::Init::Init()
|
ios_base::Init::Init()
|
||||||
{
|
{
|
||||||
istream* cin_ptr = ::new(cin) istream(::new(__cin) __stdinbuf <char>(stdin) );
|
istream* cin_ptr = ::new(cin) istream(::new(__cin) __stdinbuf <char>(stdin, state_types+0) );
|
||||||
ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf<char>(stdout));
|
ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, state_types+1));
|
||||||
ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr));
|
ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, state_types+2));
|
||||||
::new(clog) ostream(cerr_ptr->rdbuf());
|
::new(clog) ostream(cerr_ptr->rdbuf());
|
||||||
cin_ptr->tie(cout_ptr);
|
cin_ptr->tie(cout_ptr);
|
||||||
_VSTD::unitbuf(*cerr_ptr);
|
_VSTD::unitbuf(*cerr_ptr);
|
||||||
cerr_ptr->tie(cout_ptr);
|
cerr_ptr->tie(cout_ptr);
|
||||||
|
|
||||||
wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin) );
|
wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin, state_types+3) );
|
||||||
wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout));
|
wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, state_types+4));
|
||||||
wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr));
|
wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, state_types+5));
|
||||||
::new(wclog) wostream(wcerr_ptr->rdbuf());
|
::new(wclog) wostream(wcerr_ptr->rdbuf());
|
||||||
wcin_ptr->tie(wcout_ptr);
|
wcin_ptr->tie(wcout_ptr);
|
||||||
_VSTD::unitbuf(*wcerr_ptr);
|
_VSTD::unitbuf(*wcerr_ptr);
|
||||||
|
Reference in New Issue
Block a user