cast to bool optimization

This commit is contained in:
Ianos Gnatiuc 2005-10-25 06:11:09 +00:00
parent f602e0d3e3
commit 97ffdeef9d
37 changed files with 71 additions and 70 deletions

View File

@ -224,10 +224,10 @@ void AreaList::ReadGoldLast() {
(*ap)->Msgn.count = entry.msgncount;
(*ap)->unread = entry.unread;
(*ap)->marks = entry.marks;
(*ap)->isscanned = (entry.flags & 1) ? true : false;
(*ap)->isvalidchg = (entry.flags & 2) ? true : false;
(*ap)->isscanned = make_bool(entry.flags & 1);
(*ap)->isvalidchg = make_bool(entry.flags & 2);
(*ap)->UpdateAreadata();
(*ap)->isunreadchg = (entry.flags & 4) ? true : false;
(*ap)->isunreadchg = make_bool(entry.flags & 4);
(*ap)->Mark.Load(fp);
(*ap)->PMrk.Load(fp);

View File

@ -38,7 +38,7 @@ extern char* val;
void CfgHighlighturls() {
CFG->highlighturls = GetYesno(val) ? true : false;
CFG->highlighturls = make_bool(GetYesno(val));
}
// ------------------------------------------------------------------
@ -218,7 +218,7 @@ void CfgInternetrfcbody() {
void CfgInternetviagate() {
CFG->internetviagate = GetYesno(val) ? true : false;
CFG->internetviagate = make_bool(GetYesno(val));
}
// ------------------------------------------------------------------

View File

@ -170,8 +170,8 @@ extern "C" int AreaListCmp(const Area** __a, const Area** __b) {
case 'F':
case 'f':
if(*area_maybe) {
register bool amay = striinc(area_maybe, A->echoid()) ? true : false;
register bool bmay = striinc(area_maybe, B->echoid()) ? true : false;
bool amay = make_bool(striinc(area_maybe, A->echoid()));
bool bmay = make_bool(striinc(area_maybe, B->echoid()));
if((cmp = compare_two(bmay, amay)) != 0)
return cmp;

View File

@ -142,7 +142,7 @@ int DoCarboncopy(GMsg* msg, GMsg** carbon) {
HeaderView->Use(AA, msg);
HeaderView->Paint();
GMenuCarbon MenuCarbon;
ignorecc = MenuCarbon.Run(msg) ? false : true;
ignorecc = make_bool_not(MenuCarbon.Run(msg));
if(ignorecc) // Do not process carbon copies
break;
if(newline)
@ -362,7 +362,7 @@ void DoCrosspost(GMsg* msg, std::vector<int> &postareas) {
if(not ignorexc and (strnieql(ptr, "XC:", 3) or strnieql(ptr, "XP:", 3))) {
if(ask) {
GMenuCross MenuCross;
ignorexc = (CFG->crosspost != ASK) or MenuCross.Run(msg) ? false : true;
ignorexc = make_bool_not((CFG->crosspost != ASK) or MenuCross.Run(msg));
if(ignorexc) // Do not process crossposting
break;
if(newline)

View File

@ -249,7 +249,7 @@ void DoKludges(int mode, GMsg* msg, int kludges) {
if(line->kludge & kludges) {
bool waswrapped;
do {
waswrapped = (line->type & GLINE_WRAP) ? true : false;
waswrapped = make_bool(line->type & GLINE_WRAP);
line = DeleteLine(line);
} while(line and waswrapped);
}

View File

@ -235,7 +235,7 @@ static void WriteMsgs(GMsg* msg) {
SaveLines(MODE_WRITE, "\001PRN", msg, prnmargin);
}
else {
SaveLines(overwrite ? MODE_WRITE : MODE_APPEND, AA->Outputfile(), msg, prnmargin, (target & WRITE_CLIPBRD) ? true : false);
SaveLines(overwrite ? MODE_WRITE : MODE_APPEND, AA->Outputfile(), msg, prnmargin, make_bool(target & WRITE_CLIPBRD));
}
}
if(prnfp)

View File

@ -1127,7 +1127,7 @@ void IEclass::DelChar() {
setlinetype(_thisline);
// Rewrap this line
bool display = (row > maxrow / 2) ? false : true;
bool display = make_bool_not(row > maxrow / 2);
wrapdel(&currline, &col, &row, display);
if(display) {
refresh(currline, row);
@ -1553,7 +1553,7 @@ void IEclass::DeleteEOL() {
GFTRK("EditDeleteEOL");
bool _has_linefeed = (currline->txt.find('\n') != currline->txt.npos) ? true : false;
bool _has_linefeed = (currline->txt.find('\n') != currline->txt.npos);
Undo->PushItem(EDIT_UNDO_DEL_TEXT, currline);
@ -3014,7 +3014,7 @@ void UndoStack::PlayItem() {
currline = thisline;
break;
case EDIT_UNDO_PUSH_LINE:
editor->UnDelete((last_item->action & LAST_LINE) ? false : true);
editor->UnDelete(make_bool_not(last_item->action & LAST_LINE));
break;
case EDIT_UNDO_POP_LINE:
editor->DelLine();

View File

@ -84,7 +84,7 @@ static void InitCmdline(char* val) {
std::cout << "Warning: configuration filename missed for -C option, ignored.\n";
break;
case 'D':
cmdlineoldkeyw = (*val == '-') ? true : false;
cmdlineoldkeyw = (*val == '-');
break;
case 'E':
if(strieql(key, "EXPORTSOUP"))
@ -93,7 +93,7 @@ static void InitCmdline(char* val) {
strxcpy(stecho, val, sizeof(stecho));
break;
case 'F':
cmdlineforce = (*val == '-') ? false : true;
cmdlineforce = make_bool_not(*val == '-');
if(toupper(key[1]) == 'F')
cmdlineforce++;
break;
@ -112,7 +112,7 @@ static void InitCmdline(char* val) {
cmdlineimportsoup = true;
break;
case 'M':
disablesound = (*val == '-') ? false : true;
disablesound = make_bool_not(*val == '-');
break;
case 'N':
if(strieql(key, "NOSCAN"))
@ -121,7 +121,7 @@ static void InitCmdline(char* val) {
cmdlinesharemode = SH_COMPAT;
break;
case 'P':
cmdlinepriority = (*val == '-') ? false : true;
cmdlinepriority = make_bool_not(*val == '-');
break;
case 'Q':
quiet = true;
@ -134,17 +134,17 @@ static void InitCmdline(char* val) {
break;
case 'V':
quiet = false;
veryverbose = (toupper(key[1]) == 'V') ? true : false;
veryverbose = (toupper(key[1]) == 'V');
break;
case 'W':
cmdlinewriteareas = (*val == '-') ? false : true;
cmdlinewriteareas = make_bool_not(*val == '-');
break;
case 'Y':
cmdlinedebughg = (*val == '-') ? false : true;
cmdlinedebughg = make_bool_not(*val == '-');
break;
#if defined(GFTRK_ENABLE)
case 'X':
__gftrk_statusline = (*val == '-') ? false : true;
__gftrk_statusline = make_bool_not(*val == '-');
break;
case 'Z':
gftrk_set_max = atoi(val);

View File

@ -819,7 +819,7 @@ void MakeMsg(int mode, GMsg* omsg, bool ignore_replyto) {
// Set msg date and time
bool dochgdate = true;
if(mode == MODE_CHANGE) {
dochgdate = EDIT->ChangeDate() ? true : false;
dochgdate = make_bool(EDIT->ChangeDate());
if((EDIT->ChangeDate() == YES) and not msg->attr.fmu())
dochgdate = false;
}

View File

@ -267,8 +267,8 @@ void ToggleStyles() {
w_info(NULL);
if(k != Key_Esc) {
AA->adat->usestylies = (setting & 1) ? true : false;
AA->adat->hidestylies = (setting & 2) ? true : false;
AA->adat->usestylies = make_bool(setting & 1);
AA->adat->hidestylies = make_bool(setting & 2);
}
}

View File

@ -61,7 +61,7 @@ char* CvtMessageIDtoMSGID(const char* mptr, char* msgidbuf, const char* echoid,
}
else {
bool spaces = strchr(mptr, ' ') ? true : false;
bool spaces = make_bool(strchr(mptr, ' '));
dword crc32 = CRC32_MASK_CCITT;
crc32 = strCrc32(mptr, NO, crc32);

View File

@ -337,7 +337,7 @@ bool golded_search_manager::search(GMsg* msg, bool quick, bool shortcircuit) {
// Perform short-circuit logic analysis
if(shortcircuit) {
exit = found ? true : false;
exit = make_bool(found);
if(item == items.end()-1)
return exit;
}

View File

@ -59,7 +59,7 @@ int edit_string(char* buf, int buf_size, char* title, int helpcat) {
while(len and ('!' > buf2[--len]))
buf2.erase(len, 1);
strcpy(buf, buf2.c_str());
return *buf ? true : false;
return make_bool(*buf);
}

View File

@ -418,9 +418,9 @@ public:
bool pmscan() { return area->pmscan(); }
bool pmscanexcl() { return area->pmscanexcl(); }
bool pmscanincl() { return area->pmscanincl(); }
bool ismarked() const { return (marks & (1<<AL.mask)) ? true : false; }
bool ismarked() const { return make_bool(marks & (1<<AL.mask)); }
bool isnewmail() const { return (isvalidchg and isunreadchg) ? true : false; }
bool isnewmail() const { return (isvalidchg and isunreadchg); }
const char* echoid() const { return area->echoid(); }
const char* desc() const { return area->desc(); }

View File

@ -162,7 +162,8 @@ template <class T> inline int compare_two(T a, T b) { return a < b ? -1 : a
template <class T> inline T minimum_of_two(T a, T b) { return (a < b) ? a : b; }
template <class T> inline T maximum_of_two(T a, T b) { return (a > b) ? a : b; }
template <class T> inline int zero_or_one(T e) { return e ? 1 : 0; }
template <class T> inline bool make_bool(T a) { return a != 0; }
template <class T> inline bool make_bool(T a) { return !!a; }
template <class T> inline bool make_bool_not(T a) { return !a; }
// ------------------------------------------------------------------

View File

@ -96,7 +96,7 @@ int gfile::okay() {
// ------------------------------------------------------------------
int gfile::isopen() {
bool gfile::isopen() {
if((fh != -1) or (fp != NULL))
return true;

View File

@ -64,7 +64,7 @@ public:
// Handy utility functions
int okay(); // Returns non-zero if no errors were detected
int isopen(); // true if the file is open
bool isopen(); // true if the file is open
// --------------------------------------------------------------
@ -78,7 +78,7 @@ public:
~gfile(); // Destructor (closes file)
operator bool() { return isopen() ? true : false; }
operator bool() { return isopen(); }
// --------------------------------------------------------------

View File

@ -178,7 +178,7 @@ int is_dir(const char* path) {
struct stat st;
if(stat(tmp, &st) == 0)
return (st.st_mode & S_IFDIR) ? true : false;
return make_bool(st.st_mode & S_IFDIR);
return false;
}

View File

@ -182,7 +182,7 @@ bool gfuzzy::findnext() {
}
}
return start ? true : false;
return make_bool(start);
}

View File

@ -134,7 +134,7 @@ void GKbd::Init() {
OSVERSIONINFO osversion;
osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osversion);
gkbd_nt = (osversion.dwPlatformId & VER_PLATFORM_WIN32_NT) ? true : false;
gkbd_nt = make_bool(osversion.dwPlatformId & VER_PLATFORM_WIN32_NT);
gkbd_hin = CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, 0, NULL);
@ -1283,9 +1283,9 @@ gkey kbxget_raw(int mode) {
}
if((inp.EventType == KEY_EVENT) and inp.Event.KeyEvent.bKeyDown) {
bool alt_pressed = (CKS & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)) ? true : false;
bool ctrl_pressed = (CKS & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) ? true : false;
bool shift_pressed = (CKS & SHIFT_PRESSED) ? true : false;
bool alt_pressed = make_bool(CKS & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED));
bool ctrl_pressed = make_bool(CKS & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED));
bool shift_pressed = make_bool(CKS & SHIFT_PRESSED);
bool special_key = false;
k = 0;

View File

@ -135,7 +135,7 @@ public:
void HideCursor();
void ShowCursor();
int Hidden() { return hidden ? true : false; }
int Hidden() { return make_bool(hidden); }
int Enabled() { return level > GMOU_LEVEL_NONE; }

View File

@ -71,7 +71,7 @@ bool gregex::compile(const char* pattern, int cflags) {
throw_new(preg);
}
return regcomp(preg, pattern, cflgs) ? true : false;
return make_bool(regcomp(preg, pattern, cflgs));
}

View File

@ -474,7 +474,7 @@ int gsnd::is_playing() {
#if defined(__MSDOS__)
if(file_open)
return data->status == 0 ? false : true;
return make_bool_not(data->status == 0);
return false;
#elif defined(GUTLOS_FUNCS)

View File

@ -57,19 +57,19 @@ extern mail_ctype mail_ctype_global;
// ------------------------------------------------------------------
inline bool is_mail_char(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_char) ? true : false; }
inline bool is_mail_alpha(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_alpha) ? true : false; }
inline bool is_mail_ctl(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_ctl) ? true : false; }
inline bool is_mail_char(uint c) { return make_bool(mail_ctype_global.table[c] & mail_ctype::mail_char); }
inline bool is_mail_alpha(uint c) { return make_bool(mail_ctype_global.table[c] & mail_ctype::mail_alpha); }
inline bool is_mail_ctl(uint c) { return make_bool(mail_ctype_global.table[c] & mail_ctype::mail_ctl); }
inline bool is_mail_cr(uint c) { return c == CR; }
inline bool is_mail_lf(uint c) { return c == LF; }
inline bool is_mail_space(uint c) { return c == ' '; }
inline bool is_mail_htab(uint c) { return c == HT; }
inline bool is_mail_crlf(uint c) { return is_mail_cr(c) or is_mail_lf(c); }
inline bool is_mail_lwsp(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_lwsp) ? true : false; }
inline bool is_mail_special(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_special) ? true : false; }
inline bool is_mail_delimiters(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_delimiters) ? true : false; }
inline bool is_mime_tspecial(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mime_tspecial) ? true : false; }
inline bool is_mime_especial(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mime_especial) ? true : false; }
inline bool is_mail_lwsp(uint c) { return make_bool(mail_ctype_global.table[c] & mail_ctype::mail_lwsp); }
inline bool is_mail_special(uint c) { return make_bool(mail_ctype_global.table[c] & mail_ctype::mail_special); }
inline bool is_mail_delimiters(uint c) { return make_bool(mail_ctype_global.table[c] & mail_ctype::mail_delimiters); }
inline bool is_mime_tspecial(uint c) { return make_bool(mail_ctype_global.table[c] & mail_ctype::mime_tspecial); }
inline bool is_mime_especial(uint c) { return make_bool(mail_ctype_global.table[c] & mail_ctype::mime_especial); }
inline bool is_mail_atom_delimiters(uint c) { return is_mail_delimiters(c) or is_mail_ctl(c); }
inline bool is_mime_ct_token_valid(uint c) { return not (is_mail_lwsp(c) or is_mail_ctl(c) or is_mime_tspecial(c)); }

View File

@ -102,11 +102,11 @@ bool gclipbrd::writeclipbrd(const char* buf) {
if(fake_clipboard)
throw_free(fake_clipboard);
fake_clipboard = throw_strdup(buf);
return (fake_clipboard != NULL) ? true : false;
return (fake_clipboard != NULL);
}
#if defined(GUTLOS_FUNCS)
return (g_put_clip_text(buf) == 0) ? true : false;
return (g_put_clip_text(buf) == 0);
#else
return false;
#endif

View File

@ -191,7 +191,7 @@ void g_set_osicon(void) {
bool g_is_clip_available(void) {
return (winapi == NOAPI) ? false : true;
return make_bool_not(winapi == NOAPI);
}

View File

@ -254,7 +254,7 @@ void g_set_osicon(void) {
bool g_is_clip_available(void) {
return (ge_os2_hab) ? true : false;
return make_bool(ge_os2_hab);
}

View File

@ -1832,7 +1832,7 @@ void vcurset(int sline, int eline) {
vposset(gvid->numrows-1, gvid->numcols-1);
cci.dwSize = (eline and sline) ? sline : 100;
cci.bVisible = eline ? true : false;
cci.bVisible = make_bool(eline);
SetConsoleCursorInfo(gvid_hout, &cci);

View File

@ -99,7 +99,7 @@ int gwildmatch::match_internal(const char* text, const char* pattern, bool ignor
}
return -1;
case '[':
reverse = p[1] == '^' ? true : false;
reverse = (p[1] == '^');
if(reverse) // Inverted character class
p++;
matched = false;

View File

@ -48,17 +48,17 @@
static GOLD_INLINE int _wchkrow(int wrow) {
return ((wrow<0) or (wrow>((gwin.active->erow-gwin.active->border)-(gwin.active->srow+gwin.active->border)))) ? true : false;
return ((wrow<0) or (wrow>((gwin.active->erow-gwin.active->border)-(gwin.active->srow+gwin.active->border))));
}
static GOLD_INLINE int _wchkcol(int wcol) {
return ((wcol<0) or (wcol>((gwin.active->ecol-gwin.active->border)-(gwin.active->scol+gwin.active->border)))) ? true : false;
return ((wcol<0) or (wcol>((gwin.active->ecol-gwin.active->border)-(gwin.active->scol+gwin.active->border))));
}
static GOLD_INLINE int _wchkcoord(int wrow, int wcol) {
return (_wchkrow(wrow) or _wchkcol(wcol)) ? true : false;
return (_wchkrow(wrow) or _wchkcol(wcol));
}
@ -94,7 +94,7 @@ int wchkcoord(int wrow, int wcol) {
int wchkbox(int wsrow, int wscol, int werow, int wecol) {
return (_wchkcoord(wsrow,wscol) or _wchkcoord(werow,wecol) or (wsrow>werow) or (wscol>wecol)) ? true : false;
return (_wchkcoord(wsrow,wscol) or _wchkcoord(werow,wecol) or (wsrow>werow) or (wscol>wecol));
}

View File

@ -165,7 +165,7 @@ void GMnu::SetTag(int tag) {
void GMnu::Begin(int type) {
int was_horz = (stack[depth].type&M_HORZ) ? true : false;
bool was_horz = make_bool(stack[depth].type & M_HORZ);
depth++;
stack[depth].tag = -1;
stack[depth].type = type | M_SAVE;

View File

@ -1009,12 +1009,12 @@ bool gwinput::field::delete_word(bool left) {
if(entry != gwinput::entry_noedit) {
bool state = isspace(buf[buf_pos-((int) left)]) ? true : false;
bool state = make_bool(isspace(buf[buf_pos-((int) left)]));
while(left ? buf_pos > 0 : buf_pos < buf_end_pos) {
left ? delete_left() : delete_char();
if((isspace(buf[buf_pos-((int) left)]) ? true : false) != state)
if(make_bool(isspace(buf[buf_pos-((int) left)])) != state)
break;
}
return true;

View File

@ -205,7 +205,7 @@ void gareafile::ReadSpaceNtm(const char* file) {
ParseSpaceArea(val, aa);
break;
case CRC_AUTOEXPORT:
exportarea = GetYesno(val) ? true : false;
exportarea = make_bool(GetYesno(val));
break;
case CRC_ENDNETMAIL:
if(exportarea and (aa.basetype[0] != '\0'))

View File

@ -156,7 +156,7 @@ public:
FidoArea() { wide = NULL; data = NULL; }
virtual ~FidoArea() {}
virtual bool havearrivedstamp() const { return isopus() ? true : false; }
virtual bool havearrivedstamp() const { return isopus(); }
virtual bool havereceivedstamp() const { return false; }
// ----------------------------------------------------------------

View File

@ -228,7 +228,7 @@ void FidoArea::scan_area() {
GFTRK("FidoArea::scan_area");
bool was_open = data ? true : false;
bool was_open = make_bool(data);
if(not was_open)
data_open();
raw_scan(false);
@ -245,7 +245,7 @@ void FidoArea::scan_area_pm() {
GFTRK("FidoArea::scan_area_pm");
bool was_open = data ? true : false;
bool was_open = make_bool(data);
if(not was_open)
data_open();
raw_scan(true);

View File

@ -300,7 +300,7 @@ void JamArea::save_message(int __mode, gmsg* __msg, JamHdr& __hdr) {
lseekset(data->fhjhr, _idx.hdroffset);
JamHdr oldhdr;
read(data->fhjhr, &oldhdr, sizeof(JamHdr));
was_deleted = oldhdr.attribute & JAMATTR_DELETED ? true : false;
was_deleted = make_bool(oldhdr.attribute & JAMATTR_DELETED);
if(oldhdr.subfieldlen != __hdr.subfieldlen) {
oldhdr.attribute |= JAMATTR_DELETED;
oldhdr.txtlen = 0;

View File

@ -1435,7 +1435,7 @@ static bool read_config(const char *cfg, const char *argv_0) {
Addr zoneaddr;
Path buf;
bool found = (*cfg != NUL) ? true : false;
bool found = (*cfg != NUL);
if(not found) {
// Look for configfilename in the environment
const char *ptr = getenv("GOLDNODE");