HaikuDepot : Performance for Package List Updates
Performance improvements for the application updating lists of packages when the user is operating with the locale set to Russian. fixes #14513 Change-Id: I1e2514a2afbd43503ac0edfe280a856411738026 Reviewed-on: https://review.haiku-os.org/612 Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
3a44db1167
commit
6d18e980e1
@ -936,6 +936,9 @@ MainWindow::_RefreshPackageList(bool force)
|
||||
if (fSinglePackageMode)
|
||||
return;
|
||||
|
||||
if (Logger::IsDebugEnabled())
|
||||
printf("will refresh the package list\n");
|
||||
|
||||
BPackageRoster roster;
|
||||
BStringList repositoryNames;
|
||||
|
||||
@ -1221,6 +1224,9 @@ MainWindow::_RefreshPackageList(bool force)
|
||||
printf("Unknown exception occurred while resolving system "
|
||||
"dependencies.\n");
|
||||
}
|
||||
|
||||
if (Logger::IsDebugEnabled())
|
||||
printf("did refresh the package list\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018, Andrew Lindesay, <apl@lindesay.co.nz>.
|
||||
* Copyright 2017, Julian Harnath, <julian.harnath@rwth-aachen.de>.
|
||||
* Copyright 2015, Axel Dörfler, <axeld@pinc-software.de>.
|
||||
* Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
|
||||
@ -663,12 +664,16 @@ public:
|
||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||
SetLowUIColor(ViewUIColor());
|
||||
SetHighUIColor(LowUIColor(), B_DARKEN_4_TINT);
|
||||
|
||||
// constantly calculating the size is expensive so here a sensible
|
||||
// upper limit on the number of packages is arbitrarily chosen.
|
||||
fMinSize = BSize(StringWidth(_DeriveLabel(999999)) + 10,
|
||||
B_H_SCROLL_BAR_HEIGHT);
|
||||
}
|
||||
|
||||
virtual BSize MinSize()
|
||||
{
|
||||
BString label(_GetLabel());
|
||||
return BSize(StringWidth(label) + 10, B_H_SCROLL_BAR_HEIGHT);
|
||||
return fMinSize;
|
||||
}
|
||||
|
||||
virtual BSize PreferredSize()
|
||||
@ -685,13 +690,11 @@ public:
|
||||
{
|
||||
FillRect(updateRect, B_SOLID_LOW);
|
||||
|
||||
BString label(_GetLabel());
|
||||
|
||||
font_height fontHeight;
|
||||
GetFontHeight(&fontHeight);
|
||||
|
||||
BRect bounds(Bounds());
|
||||
float width = StringWidth(label);
|
||||
float width = StringWidth(fLabel);
|
||||
|
||||
BPoint offset;
|
||||
offset.x = bounds.left + (bounds.Width() - width) / 2.0f;
|
||||
@ -699,32 +702,38 @@ public:
|
||||
- (fontHeight.ascent + fontHeight.descent)) / 2.0f
|
||||
+ fontHeight.ascent;
|
||||
|
||||
DrawString(label, offset);
|
||||
DrawString(fLabel, offset);
|
||||
}
|
||||
|
||||
void SetItemCount(int32 count)
|
||||
{
|
||||
if (count == fItemCount)
|
||||
return;
|
||||
BSize minSize = MinSize();
|
||||
fItemCount = count;
|
||||
if (minSize != MinSize())
|
||||
InvalidateLayout();
|
||||
fLabel = _DeriveLabel(fItemCount);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private:
|
||||
BString _GetLabel() const
|
||||
|
||||
/*! This method is hit quite often when the list of packages in the
|
||||
table-view are updated. Derivation of the plural for some
|
||||
languages such as Russian can be slow so this method should be
|
||||
called sparingly.
|
||||
*/
|
||||
|
||||
BString _DeriveLabel(int32 count) const
|
||||
{
|
||||
static BStringFormat format(B_TRANSLATE("{0, plural, "
|
||||
"one{# item} other{# items}}"));
|
||||
|
||||
BString label;
|
||||
format.Format(label, fItemCount);
|
||||
format.Format(label, count);
|
||||
return label;
|
||||
}
|
||||
|
||||
int32 fItemCount;
|
||||
BString fLabel;
|
||||
BSize fMinSize;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user