From: Mikko Rasa Date: Mon, 6 Jun 2011 20:33:29 +0000 (+0300) Subject: Avoid using an exception in a non-error situation X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=commitdiff_plain;h=93bb92bad766d269a6bac87e00020a6158531739 Avoid using an exception in a non-error situation --- diff --git a/source/stringcodec/codec.cpp b/source/stringcodec/codec.cpp index a342242..3dc4f9a 100644 --- a/source/stringcodec/codec.cpp +++ b/source/stringcodec/codec.cpp @@ -16,17 +16,11 @@ namespace StringCodec { bool Codec::detect(const string &str) const { - Decoder *dec = create_decoder(); + Decoder *dec = create_decoder(IGNORE_ERRORS); + bool result = true; - try - { - for(string::const_iterator i=str.begin(); i!=str.end(); ) - dec->decode_char(str, i); - } - catch(const CodecError &) - { - result = false; - } + for(string::const_iterator i=str.begin(); (result && i!=str.end()); ) + result = (dec->decode_char(str, i)!=-1); delete dec;