(func: Func)
| 1234 | } |
| 1235 | |
| 1236 | function extractInField(func: Func): InField | null { |
| 1237 | if (func.name === `in`) { |
| 1238 | const firstArg = func.args[0] |
| 1239 | const secondArg = func.args[1] |
| 1240 | |
| 1241 | if ( |
| 1242 | firstArg?.type === `ref` && |
| 1243 | secondArg?.type === `val` && |
| 1244 | Array.isArray(secondArg.value) |
| 1245 | ) { |
| 1246 | let values = secondArg.value |
| 1247 | // Precompute optimization metadata once |
| 1248 | const allPrimitives = areAllPrimitives(values) |
| 1249 | let primitiveSet: Set<any> | null = null |
| 1250 | |
| 1251 | if (allPrimitives && values.length > 10) { |
| 1252 | // Build Set and dedupe values at the same time |
| 1253 | primitiveSet = new Set(values) |
| 1254 | // If we found duplicates, use the deduped array going forward |
| 1255 | if (primitiveSet.size < values.length) { |
| 1256 | values = Array.from(primitiveSet) |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | return { |
| 1261 | ref: firstArg, |
| 1262 | values, |
| 1263 | areAllPrimitives: allPrimitives, |
| 1264 | primitiveSet, |
| 1265 | } |
| 1266 | } |
| 1267 | } |
| 1268 | return null |
| 1269 | } |
| 1270 | |
| 1271 | function isComparisonSubset( |
| 1272 | subsetFunc: Func, |
no test coverage detected