Commit 4d7c0948 authored by Denis Kurz's avatar Denis Kurz Committed by Denis Kurz

Avoid mem allocs by using stack allocated initializer lists

The old code has one allocation in QList::operator<< per action.
The new code avoids heap allocs completely.
parent 5684cff5
...@@ -1098,45 +1098,47 @@ void KMMainWidget::createWidgets() ...@@ -1098,45 +1098,47 @@ void KMMainWidget::createWidgets()
//Don't use mMailActionManager->createAllActions() to save memory by not //Don't use mMailActionManager->createAllActions() to save memory by not
//creating actions that doesn't make sense. //creating actions that doesn't make sense.
const QList<StandardActionManager::Type> standardActions = QList<StandardActionManager::Type>() const auto standardActions = {
<< StandardActionManager::CreateCollection StandardActionManager::CreateCollection,
<< StandardActionManager::CopyCollections StandardActionManager::CopyCollections,
<< StandardActionManager::DeleteCollections StandardActionManager::DeleteCollections,
<< StandardActionManager::SynchronizeCollections StandardActionManager::SynchronizeCollections,
<< StandardActionManager::CollectionProperties StandardActionManager::CollectionProperties,
<< StandardActionManager::CopyItems StandardActionManager::CopyItems,
<< StandardActionManager::Paste StandardActionManager::Paste,
<< StandardActionManager::DeleteItems StandardActionManager::DeleteItems,
<< StandardActionManager::ManageLocalSubscriptions StandardActionManager::ManageLocalSubscriptions,
<< StandardActionManager::CopyCollectionToMenu StandardActionManager::CopyCollectionToMenu,
<< StandardActionManager::CopyItemToMenu StandardActionManager::CopyItemToMenu,
<< StandardActionManager::MoveItemToMenu StandardActionManager::MoveItemToMenu,
<< StandardActionManager::MoveCollectionToMenu StandardActionManager::MoveCollectionToMenu,
<< StandardActionManager::CutItems StandardActionManager::CutItems,
<< StandardActionManager::CutCollections StandardActionManager::CutCollections,
<< StandardActionManager::CreateResource StandardActionManager::CreateResource,
<< StandardActionManager::DeleteResources StandardActionManager::DeleteResources,
<< StandardActionManager::ResourceProperties StandardActionManager::ResourceProperties,
<< StandardActionManager::SynchronizeResources StandardActionManager::SynchronizeResources,
<< StandardActionManager::ToggleWorkOffline StandardActionManager::ToggleWorkOffline,
<< StandardActionManager::SynchronizeCollectionsRecursive; StandardActionManager::SynchronizeCollectionsRecursive,
};
for (StandardActionManager::Type standardAction : standardActions) { for (StandardActionManager::Type standardAction : standardActions) {
mAkonadiStandardActionManager->createAction(standardAction); mAkonadiStandardActionManager->createAction(standardAction);
} }
if (mEnableFavoriteFolderView) { if (mEnableFavoriteFolderView) {
const QList<StandardActionManager::Type> favoriteActions = QList<StandardActionManager::Type>() const auto favoriteActions = {
<< StandardActionManager::AddToFavoriteCollections StandardActionManager::AddToFavoriteCollections,
<< StandardActionManager::RemoveFromFavoriteCollections StandardActionManager::RemoveFromFavoriteCollections,
<< StandardActionManager::RenameFavoriteCollection StandardActionManager::RenameFavoriteCollection,
<< StandardActionManager::SynchronizeFavoriteCollections; StandardActionManager::SynchronizeFavoriteCollections,
};
for (StandardActionManager::Type favoriteAction : favoriteActions) { for (StandardActionManager::Type favoriteAction : favoriteActions) {
mAkonadiStandardActionManager->createAction(favoriteAction); mAkonadiStandardActionManager->createAction(favoriteAction);
} }
} }
const QList<StandardMailActionManager::Type> mailActions = { const auto mailActions = {
StandardMailActionManager::MarkAllMailAsRead, StandardMailActionManager::MarkAllMailAsRead,
StandardMailActionManager::MoveToTrash, StandardMailActionManager::MoveToTrash,
StandardMailActionManager::MoveAllToTrash, StandardMailActionManager::MoveAllToTrash,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment