Skip to content

Commit

Permalink
opt: convert for loop to for-range (#1201)
Browse files Browse the repository at this point in the history
* opt: convert for loop to for-range

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
xiaoyifang and autofix-ci[bot] authored Oct 6, 2023
1 parent 649cf17 commit db0ca76
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/article_netmgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,24 +309,24 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( QUrl c
bool search = ( id == "search" );

if ( !search ) {
for ( unsigned x = 0; x < dictionaries.size(); ++x )
if ( dictionaries[ x ]->getId() == id ) {
for ( const auto & dictionary : dictionaries )
if ( dictionary->getId() == id ) {
if ( url.scheme() == "gico" ) {
QByteArray bytes;
QBuffer buffer( &bytes );
buffer.open( QIODevice::WriteOnly );
dictionaries[ x ]->getIcon().pixmap( 64 ).save( &buffer, "PNG" );
dictionary->getIcon().pixmap( 64 ).save( &buffer, "PNG" );
buffer.close();
sptr< Dictionary::DataRequestInstant > ico = std::make_shared< Dictionary::DataRequestInstant >( true );
ico->getData().resize( bytes.size() );
memcpy( &( ico->getData().front() ), bytes.data(), bytes.size() );
return ico;
}
try {
return dictionaries[ x ]->getResource( Utils::Url::path( url ).mid( 1 ).toUtf8().data() );
return dictionary->getResource( Utils::Url::path( url ).mid( 1 ).toUtf8().data() );
}
catch ( std::exception & e ) {
gdWarning( "getResource request error (%s) in \"%s\"\n", e.what(), dictionaries[ x ]->getName().c_str() );
gdWarning( "getResource request error (%s) in \"%s\"\n", e.what(), dictionary->getName().c_str() );
return sptr< Dictionary::DataRequest >();
}
}
Expand Down

0 comments on commit db0ca76

Please sign in to comment.