@@ -30,12 +30,8 @@ template <typename T> class SmallVectorImpl;
3030
3131namespace details {
3232class CharSetConverterImplBase {
33- public:
34- virtual ~CharSetConverterImplBase () = default ;
35-
36- // / Resets the converter to the initial state.
37- virtual void reset () = 0;
3833
34+ private:
3935 // / Converts a string.
4036 // / \param[in] Source source string
4137 // / \param[out] Result container for converted string
@@ -55,12 +51,21 @@ class CharSetConverterImplBase {
5551 // / In case of an error, the result string contains the successfully converted
5652 // / part of the input string.
5753 // /
58-
59- std::error_code convert (StringRef Source,
60- SmallVectorImpl<char > &Result) const ;
61-
6254 virtual std::error_code convertString (StringRef Source,
6355 SmallVectorImpl<char > &Result) = 0;
56+
57+ // / Resets the converter to the initial state.
58+ virtual void reset () = 0;
59+
60+ public:
61+ virtual ~CharSetConverterImplBase () = default ;
62+
63+ // / Converts a string and resets the converter to the initial state.
64+ std::error_code convert (StringRef Source, SmallVectorImpl<char > &Result) {
65+ auto EC = convertString (Source, Result);
66+ reset ();
67+ return EC;
68+ }
6469};
6570} // namespace details
6671
@@ -118,15 +123,12 @@ class CharSetConverter {
118123 // / \return error code in case something went wrong
119124 std::error_code convert (StringRef Source,
120125 SmallVectorImpl<char > &Result) const {
121- auto EC = Converter->convertString (Source, Result);
122- Converter->reset ();
123- return EC;
126+ return Converter->convert (Source, Result);
124127 }
125128
126129 ErrorOr<std::string> convert (StringRef Source) const {
127130 SmallString<100 > Result;
128- auto EC = Converter->convertString (Source, Result);
129- Converter->reset ();
131+ auto EC = Converter->convert (Source, Result);
130132 if (!EC)
131133 return std::string (Result);
132134 return EC;
0 commit comments