From 57a41edbe07422560d294d72922c8d2778bbb78d Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 19 Aug 2016 19:53:10 +0200 Subject: [PATCH] Don't pretend to move columns when they aren't to be moved This is purely a performance optimisation. It reduced the number of calls to Table::setField() from three to two when the user only wants to rename a field in EditTableDialog and not move it. --- src/sqlitedb.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 9f5638e9..c13c9c42 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -976,11 +976,15 @@ bool DBBrowserDB::renameColumn(const QString& tablename, const QString& name, sq } else { // We want to modify it - // Move field int index = newSchema.findField(name); - sqlb::FieldPtr temp = newSchema.fields().at(index); - newSchema.setField(index, newSchema.fields().at(index + move)); - newSchema.setField(index + move, temp); + + // Move field + if(move) + { + sqlb::FieldPtr temp = newSchema.fields().at(index); + newSchema.setField(index, newSchema.fields().at(index + move)); + newSchema.setField(index + move, temp); + } // Get names of fields to select from old table now - after the field has been moved and before it might be renamed for(int i=0;i