* compare_path_costs * Return -1, 0, or +1 according as path1 is cheaper, the same cost, * or more expensive than path2 for the specified criterion. */
| 93 | * or more expensive than path2 for the specified criterion. |
| 94 | */ |
| 95 | int |
| 96 | compare_path_costs(Path *path1, Path *path2, CostSelector criterion) |
| 97 | { |
| 98 | if (criterion == STARTUP_COST) |
| 99 | { |
| 100 | if (path1->startup_cost < path2->startup_cost) |
| 101 | return -1; |
| 102 | if (path1->startup_cost > path2->startup_cost) |
| 103 | return +1; |
| 104 | |
| 105 | /* |
| 106 | * If paths have the same startup cost (not at all unlikely), order |
| 107 | * them by total cost. |
| 108 | */ |
| 109 | if (path1->total_cost < path2->total_cost) |
| 110 | return -1; |
| 111 | if (path1->total_cost > path2->total_cost) |
| 112 | return +1; |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | if (path1->total_cost < path2->total_cost) |
| 117 | return -1; |
| 118 | if (path1->total_cost > path2->total_cost) |
| 119 | return +1; |
| 120 | |
| 121 | /* |
| 122 | * If paths have the same total cost, order them by startup cost. |
| 123 | */ |
| 124 | if (path1->startup_cost < path2->startup_cost) |
| 125 | return -1; |
| 126 | if (path1->startup_cost > path2->startup_cost) |
| 127 | return +1; |
| 128 | } |
| 129 | return 0; |
| 130 | } |
| 131 | |
| 132 | /* |
| 133 | * compare_path_fractional_costs |
no outgoing calls
no test coverage detected