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.
This commit is contained in:
Martin Kleusberg
2016-08-19 19:53:10 +02:00
parent c0fe719bd5
commit 57a41edbe0

View File

@@ -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<newSchema.fields().count();++i)