| 105 | /// Replace unassigned shared variables by fresh, yet equal variables |
| 106 | template<class Var> |
| 107 | forceinline void |
| 108 | unshare(Home home, VarArgArray<Var>& x, IntPropLevel ipl) { |
| 109 | int n=x.size(); |
| 110 | if (n < 2) |
| 111 | return; |
| 112 | |
| 113 | Region r; |
| 114 | Var** y = r.alloc<Var*>(n); |
| 115 | for (int i=0; i<n; i++) |
| 116 | y[i]=&x[i]; |
| 117 | |
| 118 | VarPtrLess<Var> vpl; |
| 119 | Support::quicksort<Var*,VarPtrLess<Var> >(y,n,vpl); |
| 120 | |
| 121 | // Replace all shared variables with new and equal variables |
| 122 | for (int i=0; i<n;) { |
| 123 | int j=i++; |
| 124 | while ((i<n) && (y[j]->varimp() == y[i]->varimp())) |
| 125 | i++; |
| 126 | if (!y[j]->assigned()) |
| 127 | link(home,&y[j],i-j,ipl); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | }}} |
| 132 |
no test coverage detected