mirror of
https://github.com/google/googletest.git
synced 2025-03-10 17:36:10 +00:00
Remove duplicate code
This commit is contained in:
parent
a6b146dfdd
commit
2960aa54e2
@ -2894,27 +2894,17 @@ WORD GetColorAttribute(GTestColor color) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetBgOffset(WORD background_mask) {
|
int GetBitOffset(WORD color_mask) {
|
||||||
if (background_mask == 0) return 0;
|
if (color_mask == 0) return 0;
|
||||||
|
|
||||||
int bitOffset = 0;
|
int bitOffset = 0;
|
||||||
while((background_mask & 1) == 0) {
|
while((color_mask & 1) == 0) {
|
||||||
background_mask >>= 1;
|
color_mask >>= 1;
|
||||||
++bitOffset;
|
++bitOffset;
|
||||||
}
|
}
|
||||||
return bitOffset;
|
return bitOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetFgOffset(WORD foreground_mask) {
|
|
||||||
if (foreground_mask == 0) return 0;
|
|
||||||
|
|
||||||
int bitOffset = 0;
|
|
||||||
while((foreground_mask & 1) == 0) {
|
|
||||||
foreground_mask >>= 1;
|
|
||||||
++bitOffset;
|
|
||||||
}
|
|
||||||
return bitOffset;
|
|
||||||
}
|
|
||||||
WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
|
WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
|
||||||
// Let's reuse the BG
|
// Let's reuse the BG
|
||||||
static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||||
@ -2922,8 +2912,8 @@ WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
|
|||||||
const WORD existing_bg = old_color_attrs & background_mask;
|
const WORD existing_bg = old_color_attrs & background_mask;
|
||||||
|
|
||||||
WORD new_color = GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;
|
WORD new_color = GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;
|
||||||
static const int bg_bitOffset = GetBgOffset(background_mask);
|
static const int bg_bitOffset = GetBitOffset(background_mask);
|
||||||
static const int fg_bitOffset = GetFgOffset(foreground_mask);
|
static const int fg_bitOffset = GetBitOffset(foreground_mask);
|
||||||
|
|
||||||
if (((new_color & background_mask) >> bg_bitOffset) == ((new_color & foreground_mask) >> fg_bitOffset)) {
|
if (((new_color & background_mask) >> bg_bitOffset) == ((new_color & foreground_mask) >> fg_bitOffset)) {
|
||||||
new_color ^= FOREGROUND_INTENSITY; //invert intensity
|
new_color ^= FOREGROUND_INTENSITY; //invert intensity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user