diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-09-20 00:46:09 -0700 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-09-20 00:47:20 -0700 |
commit | 25cce38f50123d0ca88fb0920df6acdde05a53ff (patch) | |
tree | c005888083c8899cbf41513897c6477f0ccf90eb | |
parent | 9c539f92ab9420bc94037681da3d1fce4878e01b (diff) |
Inline widen_ascii to get rid of an extra strlen call
Also since this function is only used once and is not defined in regular mode
to avoid warnings this simplifies code a bit.
-rw-r--r-- | src/pugixml.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index da0e9e4..413e342 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -221,15 +221,6 @@ PUGI__NS_BEGIN return static_cast<size_t>(end - s); #endif } - -#ifdef PUGIXML_WCHAR_MODE - // Convert string to wide string, assuming all symbols are ASCII - PUGI__FN void widen_ascii(wchar_t* dest, const char* source) - { - for (const char* i = source; *i; ++i) *dest++ = *i; - *dest = 0; - } -#endif PUGI__NS_END // auto_ptr-like object for exception recovery @@ -4563,13 +4554,15 @@ PUGI__NS_BEGIN // set value with conversion functions template <typename String, typename Header> - PUGI__FN bool set_value_buffer(String& dest, Header& header, uintptr_t header_mask, char (&buf)[128]) + PUGI__FN bool set_value_ascii(String& dest, Header& header, uintptr_t header_mask, char (&buf)[128]) { #ifdef PUGIXML_WCHAR_MODE char_t wbuf[128]; - impl::widen_ascii(wbuf, buf); - return strcpy_insitu(dest, header, header_mask, wbuf, strlength(wbuf)); + size_t offset = 0; + for (; buf[offset]; ++offset) wbuf[offset] = buf[offset]; + + return strcpy_insitu(dest, header, header_mask, wbuf, offset); #else return strcpy_insitu(dest, header, header_mask, buf, strlength(buf)); #endif @@ -4601,7 +4594,7 @@ PUGI__NS_BEGIN char buf[128]; sprintf(buf, "%.9g", value); - return set_value_buffer(dest, header, header_mask, buf); + return set_value_ascii(dest, header, header_mask, buf); } template <typename String, typename Header> @@ -4610,7 +4603,7 @@ PUGI__NS_BEGIN char buf[128]; sprintf(buf, "%.17g", value); - return set_value_buffer(dest, header, header_mask, buf); + return set_value_ascii(dest, header, header_mask, buf); } template <typename String, typename Header> |