| 281 | |
| 282 | |
| 283 | void Scheduler::FinetuneGroups() |
| 284 | { |
| 285 | listType * lp; |
| 286 | int strain, key, b1, b2; |
| 287 | int numGroupsOrig = numGroups; |
| 288 | |
| 289 | for (int g = 0; g < numGroupsOrig; g++) |
| 290 | { |
| 291 | strain = group[g].strain; |
| 292 | key = group[g].hash; |
| 293 | |
| 294 | lp = &list[strain][key]; |
| 295 | |
| 296 | if (lp->length == 1) |
| 297 | continue; |
| 298 | |
| 299 | else if (lp->length == 2) |
| 300 | { |
| 301 | // This happens quite often, so worth optimizing. |
| 302 | |
| 303 | b1 = lp->first; |
| 304 | b2 = hands[lp->first].next; |
| 305 | |
| 306 | bool match = false; |
| 307 | if (hands[b1].spareKey == hands[b2].spareKey) |
| 308 | { |
| 309 | // It is now extremely likely that it is a repeat hand, |
| 310 | // but we have to be sure. |
| 311 | match = true; |
| 312 | for (int h = 0; h < DDS_HANDS && match; h++) |
| 313 | for (int s = 0; s < DDS_SUITS && match; s++) |
| 314 | if (hands[b1].remainCards[h][s] != hands[b2].remainCards[h][s]) |
| 315 | match = false; |
| 316 | } |
| 317 | |
| 318 | if (match) |
| 319 | continue; |
| 320 | |
| 321 | // Leave the first hand in place. |
| 322 | hands[lp->first].next = -1; |
| 323 | lp->last = lp->first; |
| 324 | lp->length = 1; |
| 325 | |
| 326 | // Move the second hand to the special list. |
| 327 | lp = &list[5][extraGroups]; |
| 328 | |
| 329 | lp->first = b2; |
| 330 | lp->last = b2; |
| 331 | lp->length = 1; |
| 332 | |
| 333 | group[numGroups].strain = 5; |
| 334 | group[numGroups].hash = extraGroups; |
| 335 | |
| 336 | numGroups++; |
| 337 | extraGroups++; |
| 338 | } |
| 339 | |
| 340 | else |
nothing calls this directly
no outgoing calls
no test coverage detected