| 214 | } |
| 215 | |
| 216 | const SortedValueList* LookupValueList::init(thread_db* tdbb, Request* request) const |
| 217 | { |
| 218 | auto createList = [&]() |
| 219 | { |
| 220 | const auto sortedList = FB_NEW_POOL(*tdbb->getDefaultPool()) |
| 221 | SortedValueList(*tdbb->getDefaultPool(), m_values.getCount()); |
| 222 | |
| 223 | sortedList->setSortMode(FB_ARRAY_SORT_MANUAL); |
| 224 | |
| 225 | for (const auto value : m_values) |
| 226 | { |
| 227 | const auto valueDesc = EVL_expr(tdbb, request, value); |
| 228 | sortedList->add(SortValueItem(value, valueDesc)); |
| 229 | } |
| 230 | |
| 231 | sortedList->sort(); |
| 232 | |
| 233 | return sortedList; |
| 234 | }; |
| 235 | |
| 236 | // Non-zero impure offset means that the list expression is invariant, |
| 237 | // so the sorted list can be cached inside the impure area |
| 238 | |
| 239 | if (m_impureOffset) |
| 240 | { |
| 241 | const auto impure = request->getImpure<impure_value>(m_impureOffset); |
| 242 | auto sortedList = impure->vlu_misc.vlu_sortedList; |
| 243 | |
| 244 | if (!(impure->vlu_flags & VLU_computed)) |
| 245 | { |
| 246 | delete impure->vlu_misc.vlu_sortedList; |
| 247 | impure->vlu_misc.vlu_sortedList = nullptr; |
| 248 | |
| 249 | sortedList = impure->vlu_misc.vlu_sortedList = createList(); |
| 250 | impure->vlu_flags |= VLU_computed; |
| 251 | } |
| 252 | |
| 253 | return sortedList; |
| 254 | } |
| 255 | |
| 256 | // Otherwise, create a temporary list for early evaluation during index lookup |
| 257 | |
| 258 | return createList(); |
| 259 | } |
| 260 | |
| 261 | bool LookupValueList::find(thread_db* tdbb, Request* request, const ValueExprNode* value, const dsc* desc) const |
| 262 | { |
no test coverage detected