hrev47866 adds 2 changesets to branch 'master' old head: c98378e51ae02d8ad6e833c7eb8223a10cbd46f5 new head: 2c8da965461005ce6d4c8ba1660c9ea0f3032a39 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=2c8da96+%5Ec98378e ---------------------------------------------------------------------------- 21f8e58: Optimize BUrl copy. BUrl is passed by value in many places, and we should make sure this is as efficient as possible. There is little point in initializing all the strings then overwriting them by using the copy constructor, when we can set them directly. 2c8da96: WebPositive: improve "show bookmark bar" menu item * Disable the menu item when the folder doesn't exist, as the bar won't show in that case. * Use a mark on the item to tell wether the bar is visible, rather than changing its label * Simplify the logic for hiding and showing the bar. It is safe to call _ShowBookmarkBar even if the bar doesn't exist, so no need to check for it everywhere. Fixes #11199. [ Adrien Destugues <pulkomandy@xxxxxxxxx> ] ---------------------------------------------------------------------------- 2 files changed, 43 insertions(+), 28 deletions(-) src/apps/webpositive/BrowserWindow.cpp | 33 ++++++++++++-------------- src/kits/network/libnetapi/Url.cpp | 38 ++++++++++++++++++++++-------- ############################################################################ Commit: 21f8e588da367f19096cc976f037a0855d5f3996 URL: http://cgit.haiku-os.org/haiku/commit/?id=21f8e58 Author: Adrien Destugues <pulkomandy@xxxxxxxxx> Date: Tue Sep 16 13:30:01 2014 UTC Optimize BUrl copy. BUrl is passed by value in many places, and we should make sure this is as efficient as possible. There is little point in initializing all the strings then overwriting them by using the copy constructor, when we can set them directly. ---------------------------------------------------------------------------- diff --git a/src/kits/network/libnetapi/Url.cpp b/src/kits/network/libnetapi/Url.cpp index 3bfd4e3..76a050d 100644 --- a/src/kits/network/libnetapi/Url.cpp +++ b/src/kits/network/libnetapi/Url.cpp @@ -66,17 +66,35 @@ BUrl::BUrl(const BUrl& other) : BArchivable(), fUrlString(), - fProtocol(), - fUser(), - fPassword(), - fHost(), - fPort(0), - fPath(), - fRequest(), - fHasHost(false), - fHasFragment(false) + fProtocol(other.fProtocol), + fUser(other.fUser), + fPassword(other.fPassword), + fHost(other.fHost), + fPort(other.fPort), + fPath(other.fPath), + fRequest(other.fRequest), + fFragment(other.fFragment), + fUrlStringValid(other.fUrlStringValid), + fAuthorityValid(other.fAuthorityValid), + fUserInfoValid(other.fUserInfoValid), + fHasProtocol(other.fHasProtocol), + fHasUserName(other.fHasUserName), + fHasPassword(other.fHasPassword), + fHasHost(other.fHasHost), + fHasPort(other.fHasPort), + fHasPath(other.fHasPath), + fHasRequest(other.fHasRequest), + fHasFragment(other.fHasFragment) { - *this = other; + if (fUrlStringValid) + fUrlString = other.fUrlString; + + if (fAuthorityValid) + fAuthority = other.fAuthority; + + if (fUserInfoValid) + fUserInfo = other.fUserInfo; + } ############################################################################ Revision: hrev47866 Commit: 2c8da965461005ce6d4c8ba1660c9ea0f3032a39 URL: http://cgit.haiku-os.org/haiku/commit/?id=2c8da96 Author: Adrien Destugues <pulkomandy@xxxxxxxxx> Date: Tue Sep 16 15:40:34 2014 UTC Ticket: https://dev.haiku-os.org/ticket/11199 WebPositive: improve "show bookmark bar" menu item * Disable the menu item when the folder doesn't exist, as the bar won't show in that case. * Use a mark on the item to tell wether the bar is visible, rather than changing its label * Simplify the logic for hiding and showing the bar. It is safe to call _ShowBookmarkBar even if the bar doesn't exist, so no need to check for it everywhere. Fixes #11199. ---------------------------------------------------------------------------- diff --git a/src/apps/webpositive/BrowserWindow.cpp b/src/apps/webpositive/BrowserWindow.cpp index 5d6ff08..df4f679 100644 --- a/src/apps/webpositive/BrowserWindow.cpp +++ b/src/apps/webpositive/BrowserWindow.cpp @@ -455,7 +455,7 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings, menu->AddItem(new BMenuItem(B_TRANSLATE("Reload"), new BMessage(RELOAD), 'R')); // the label will be replaced with the appropriate text later on - fBookmarkBarMenuItem = new BMenuItem("Show/Hide bookmark bar", + fBookmarkBarMenuItem = new BMenuItem(B_TRANSLATE("Show bookmark bar"), new BMessage(SHOW_HIDE_BOOKMARK_BAR)); menu->AddItem(fBookmarkBarMenuItem); menu->AddSeparatorItem(); @@ -500,8 +500,11 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings, BEntry bookmarkBar(&barDir, "Bookmark bar"); entry_ref bookmarkBarRef; // TODO we could also check if the folder is empty here. - if (bookmarkBar.Exists() && bookmarkBar.GetRef(&bookmarkBarRef) == B_OK) + if (bookmarkBar.Exists() && bookmarkBar.GetRef(&bookmarkBarRef) == B_OK) { fBookmarkBar = new BookmarkBar("Bookmarks", this, &bookmarkBarRef); + fBookmarkBarMenuItem->SetEnabled(true); + } else + fBookmarkBarMenuItem->SetEnabled(false); } // Back, Forward, Stop & Home buttons @@ -608,15 +611,10 @@ BrowserWindow::BrowserWindow(BRect frame, SettingsMessage* appSettings, .Add(toggleFullscreenButton, 0.0f) ; - if (fBookmarkBar != NULL) { - if (fAppSettings->GetValue(kSettingsShowBookmarkBar, true)) { - // We need to hide the bookmark bar and then show it again - // to save the setting and set the menu item label. - fBookmarkBar->Hide(); - _ShowBookmarkBar(true); - } else - _ShowBookmarkBar(false); - } + if (fAppSettings->GetValue(kSettingsShowBookmarkBar, true)) + _ShowBookmarkBar(true); + else + _ShowBookmarkBar(false); fSavePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(this), NULL, 0, false); @@ -827,8 +825,7 @@ BrowserWindow::MessageReceived(BMessage* message) break; case SHOW_HIDE_BOOKMARK_BAR: - if (fBookmarkBar != NULL) - _ShowBookmarkBar(fBookmarkBar->IsHidden()); + _ShowBookmarkBar(fBookmarkBar->IsHidden()); break; case GOTO_URL: @@ -2606,16 +2603,16 @@ BrowserWindow::_HandlePageSourceResult(const BMessage* message) void BrowserWindow::_ShowBookmarkBar(bool show) { + fBookmarkBarMenuItem->SetMarked(show); + if (fBookmarkBar == NULL || fBookmarkBar->IsHidden() != show) return; fAppSettings->SetValue(kSettingsShowBookmarkBar, show); - fBookmarkBarMenuItem->SetLabel(show - ? B_TRANSLATE("Hide bookmark bar") - : B_TRANSLATE("Show bookmark bar")); - if (show) + if (show) { fBookmarkBar->Show(); - else + } else { fBookmarkBar->Hide(); + } }