well, this is kind of stupid but you could write ismousebutton down from smatrzkid's post as
'return LeftButton?Mouse::IsLeftDown:Mouse::IsRightDown;' save like 10 bytes of source size lol
edit:
is this the code you are talking about??
Code:
void ColorFind::FindColorsSpiralTolerance(int x, int y, std::vector<POINT>& Points, int color,
574 int xs, int ys, int xe, int ye, int Tolerance)
575 {
576 int i = 0;
577 int pointsSize;
578 double* distances;
579
580 ColorFind::FindColorsTolerance(Points, color, xs, ys, xe, ye, Tolerance);
581 pointsSize = Points.size();
582
583 distances = new double[pointsSize];
584
585 for(int i = 0; i < pointsSize; ++i)
586 distances[i] = sqrt(((Points[i].x - x) * (Points[i].x - x)) +
587 ((Points[i].y - y) * (Points[i].y - y)));
588
589 i = 0;
590
591 // Heap Sort, Yeay!
592 while(i < pointsSize)
593 {
594 int j = i;
595 double minDistance = 2000;
596 int closestPoint;
597 for (j = i; j < pointsSize; ++j)
598 {
599 if(distances[j] < minDistance)
600 {
601 closestPoint = j;
602 minDistance = distances[j];
603 }
604 }
605 std::swap(distances[i], distances[closestPoint]);
606 std::swap(Points[i], Points[closestPoint]);
607 ++i;
608 }
609 delete[] distances;
610 }
well, first off dont allocate a bunch of doubles, ints, or unsigned is good enough because you don't really need to calculate the sqrt of all those pts.
it is enough to know that if ((x1 - x2)^2 + (y2 - y2)^2) is greater than that of another pt then the sqrt will obviously be greater (plus more accuracy that way).
edit 2:
Code:
bool Keyboard::IsFunctionKeyDown(int Key)
111 {
112 int newKey;
113
114 switch (Key) // I wish there was a better way to do this, but alas none of
115 { // the key codes are in order :(
116 case 0:
117 newKey = VK_SHIFT;
118 break;
119 case 1:
120 newKey = VK_CONTROL;
121 break;
122 case 2:
123 newKey = VK_MENU;
124 break;
125 case 3:
126 newKey = VK_LSHIFT;
127 break;
128 case 4:
129 newKey = VK_LCONTROL;
130 break;
131 case 5:
132 newKey = VK_LMENU;
133 break;
134 case 6:
135 newKey = VK_RSHIFT;
136 break;
137 case 7:
138 newKey = VK_RCONTROL;
139 break;
140 case 8:
141 newKey = VK_RMENU;
142 break;
143 default:
144 newKey = 0;
145 }
146 }
well, isn't a better way to do a simple bin search? like this
Code:
return
(x<5)?
((x<3)?
((x<2)?
((x<1)?
(VK_SHIFT):
(VK_CONTROL)):
(VK_MENU)):
((x<4)?
(VK_LSHIFT):
(VK_LCONTROL))):
((x<8)?
((x<7)?
((x<6)?
(VK_LMENU):
(VK_RSHIFT)):
(VK_RCONTROL)):
((x<9)?
(VK_RMENU):
(0)));
erm? hope that works..(your probably saving at least 2 nanoseconds with that lol)