From a5da01c0449c4237280021a11271cd433707a523 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 30 Jan 2019 20:16:42 -0800 Subject: [PATCH] Remove useless null pointer checks Cache can't be null, since it's a member of an extant object. Change-Id: Id98140e1c2f0426cabbefffd157ed3cdd62a8bba Reviewed-by: Lars Knoll --- src/corelib/codecs/qtextcodec.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 85cfcdbf48..8639e4f2f0 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -544,11 +544,9 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name) #if !QT_CONFIG(icu) QTextCodecCache *cache = &globalData->codecCache; QTextCodec *codec; - if (cache) { - codec = cache->value(name); - if (codec) - return codec; - } + codec = cache->value(name); + if (codec) + return codec; for (TextCodecListConstIt it = globalData->allCodecs.constBegin(), cend = globalData->allCodecs.constEnd(); it != cend; ++it) { QTextCodec *cursor = *it; @@ -560,8 +558,7 @@ QTextCodec *QTextCodec::codecForName(const QByteArray &name) QList aliases = cursor->aliases(); for (ByteArrayListConstIt ait = aliases.constBegin(), acend = aliases.constEnd(); ait != acend; ++ait) { if (qTextCodecNameMatch(*ait, name)) { - if (cache) - cache->insert(name, cursor); + cache->insert(name, cursor); return cursor; } }