@@ -453,6 +453,7 @@ void Fhex::compare(QString filename) {
453453 unsigned long changes = res.size ();
454454 unsigned long start_offset = 0 ;
455455 unsigned long offset = 0 ;
456+ int limit = MAX_DIFF_BYTES ; // Show maximum 3000 different bytes
456457 QByteArray diff_bytes;
457458 for (pair<unsigned long , uint8_t > p : res) {
458459 if (offset == 0 ) {
@@ -461,16 +462,20 @@ void Fhex::compare(QString filename) {
461462 listOffsets->addItem (" 0x" + QString::number (start_offset, 16 ));
462463 }
463464 if (p.first - offset > 0 ) {
464- addFloatingLabel (start_offset, static_cast <int >(diff_bytes.size ()), " Compared file:\r\n " + diff_bytes.toHex (' ' ) + " \r\n -----------\r\n " + diff_bytes, DIFF_STYLE );
465+ if (limit > 0 )
466+ addFloatingLabel (start_offset, static_cast <int >(diff_bytes.size ()), " Compared file:\r\n " + diff_bytes.toHex (' ' ) + " \r\n -----------\r\n " + diff_bytes, DIFF_STYLE );
465467 diff_bytes.clear ();
466468 offset = 0 ;
467469 } else {
468470 offset++;
469471 }
470472 diff_bytes.push_back (static_cast <char >(p.second ));
473+ if (limit > 0 )
474+ limit--;
471475 }
472476 if (diff_bytes.size () > 0 ) {
473- addFloatingLabel (start_offset, static_cast <int >(diff_bytes.size ()), " After:\r\n " + diff_bytes.toHex (' ' ) + " \r\n -----------\r\n " + diff_bytes, DIFF_STYLE );
477+ if (limit > 0 )
478+ addFloatingLabel (start_offset, static_cast <int >(diff_bytes.size ()), " After:\r\n " + diff_bytes.toHex (' ' ) + " \r\n -----------\r\n " + diff_bytes, DIFF_STYLE );
474479 diff_bytes.clear ();
475480 }
476481
@@ -480,6 +485,17 @@ void Fhex::compare(QString filename) {
480485 this ->statusBar .setText (" Found " + QString::number (changes) + " different bytes" );
481486 listOffsets->setVisible (true );
482487 }
488+
489+ if (limit == 0 ) {
490+ QMessageBox msgBox;
491+ msgBox.setText (" The output displays only the first " + QString::number (MAX_DIFF_BYTES ) + " different bytes for performance reasons." );
492+ msgBox.setStandardButtons (QMessageBox::Ok);
493+ msgBox.setDefaultButton (QMessageBox::Ok);
494+ msgBox.setIcon (QMessageBox::Icon::Warning);
495+ msgBox.setWindowTitle (this ->windowTitle ());
496+ msgBox.setWindowIcon (this ->windowIcon ());
497+ msgBox.exec ();
498+ }
483499}
484500
485501void Fhex::on_menu_file_save_click () {
0 commit comments