Follows the suggestion by Stefano and caches the square root.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16904 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2006-03-27 22:31:49 +00:00
parent 5deac87dd2
commit 74e8df0e6e

View File

@ -40,10 +40,12 @@ void
WorkspacesLayer::_GetGrid(int32& columns, int32& rows)
{
DesktopSettings settings(Window()->Desktop());
int32 count = settings.WorkspacesCount();
int32 squareRoot = sqrt(count);
rows = 1;
for (int32 i = 2; i <= sqrt(count); i++) {
for (int32 i = 2; i <= squareRoot; i++) {
if (count % i == 0)
rows = i;
}