From 667fb05a35703ccee5a9493a7d2c33b83cb96bc8 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 1 May 2010 13:20:47 +0200 Subject: [PATCH] Kill float and double --- src/gmenu2x.cpp | 9 +++------ src/menu.cpp | 10 +++++++--- src/utilities.cpp | 13 +------------ src/utilities.h | 4 ---- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index 0be967f..d668a13 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -1867,12 +1867,9 @@ string GMenu2X::getDiskFree() { int ret = statvfs("/card/gmenu2x", &b); if (ret==0) { - /*unsigned long free = b.f_bfree*b.f_frsize/1048576; - unsigned long total = b.f_blocks*b.f_frsize/1048576; - ss << free << "/" << total << "MB";*/ - double free = (double)b.f_bfree * (double)b.f_bsize / 1048576.0; - double total = (double)b.f_blocks * (double)b.f_frsize / 1048576.0; - ss << (unsigned long)free << "/" << (unsigned long)total << "MB"; + unsigned long long free = b.f_bfree * b.f_bsize / 1048576; + unsigned long long total = b.f_blocks * b.f_frsize / 1048576; + ss << free << "/" << total << "MB"; ss >> df; } else cout << "\033[0;34mGMENU2X:\033[0;31m statvfs failed with error '" << strerror(errno) << "'\033[0m" << endl; return df; diff --git a/src/menu.cpp b/src/menu.cpp index 158219c..7a3f631 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -364,10 +364,13 @@ void Menu::linkRight() { setLinkIndex(iLink+1); } +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) + void Menu::linkUp() { int l = iLink-gmenu2x->linkColumns; if (l<0) { - uint rows = (uint)ceil(sectionLinks()->size()/(double)gmenu2x->linkColumns); + unsigned int rows; + rows = DIV_ROUND_UP(sectionLinks()->size(), gmenu2x->linkColumns); l = (rows*gmenu2x->linkColumns)+l; if (l >= (int)sectionLinks()->size()) l -= gmenu2x->linkColumns; @@ -378,8 +381,9 @@ void Menu::linkUp() { void Menu::linkDown() { uint l = iLink+gmenu2x->linkColumns; if (l >= sectionLinks()->size()) { - uint rows = (uint)ceil(sectionLinks()->size()/(double)gmenu2x->linkColumns); - uint curCol = (uint)ceil((iLink+1)/(double)gmenu2x->linkColumns); + unsigned int rows, curCol; + rows = DIV_ROUND_UP(sectionLinks()->size(), gmenu2x->linkColumns); + curCol = DIV_ROUND_UP(iLink + 1, gmenu2x->linkColumns); if (rows > curCol) l = sectionLinks()->size()-1; else diff --git a/src/utilities.cpp b/src/utilities.cpp index 029b586..77630d7 100644 --- a/src/utilities.cpp +++ b/src/utilities.cpp @@ -123,16 +123,6 @@ string evalStrConf (string *val, string def) { return *val; } -float max (float a, float b) { - return a>b ? a : b; -} -float min (float a, float b) { - return a &vec, const string &str, const string &delim, bool destructive) { vec.clear(); @@ -188,7 +178,6 @@ string cmdclean (string cmdline) { int intTransition(int from, int to, long tickStart, long duration, long tickNow) { if (tickNow<0) tickNow = SDL_GetTicks(); - float elapsed = (float)(tickNow-tickStart)/duration; + return constrain(((tickNow-tickStart) * (to-from)) / duration, from, to); // elapsed increments - return constrain(round(elapsed*(to-from)),from,to); } diff --git a/src/utilities.h b/src/utilities.h index fef6f12..486dfcb 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -71,10 +71,6 @@ int evalIntConf (int *val, int def, int imin, int imax); string evalStrConf (string val, string def); string evalStrConf (string *val, string def); -float max (float a, float b); -float min (float a, float b); -float constrain (float x, float imin, float imax); - bool split (vector &vec, const string &str, const string &delim, bool destructive=true); int intTransition(int from, int to, long int tickStart, long duration=500, long tickNow=-1);