##// END OF EJS Templates
revset: remove "small" argument from "_optimize"...
Jun Wu -
r34273:53fb09c7 default
parent child Browse files
Show More
@@ -353,20 +353,16 b' def analyze(x):'
353 353 """
354 354 return _analyze(x)
355 355
356 def _optimize(x, small):
356 def _optimize(x):
357 357 if x is None:
358 358 return 0, x
359 359
360 smallbonus = 1
361 if small:
362 smallbonus = .5
363
364 360 op = x[0]
365 361 if op in ('string', 'symbol'):
366 return smallbonus, x # single revisions are small
362 return 0.5, x # single revisions are small
367 363 elif op == 'and':
368 wa, ta = _optimize(x[1], True)
369 wb, tb = _optimize(x[2], True)
364 wa, ta = _optimize(x[1])
365 wb, tb = _optimize(x[2])
370 366 w = min(wa, wb)
371 367
372 368 # (draft/secret/_notpublic() & ::x) have a fast path
@@ -397,12 +393,12 b' def _optimize(x, small):'
397 393 else:
398 394 s = '\0'.join(t[1] for w, t in ss)
399 395 y = _build('_list(_)', ('string', s))
400 w, t = _optimize(y, False)
396 w, t = _optimize(y)
401 397 ws.append(w)
402 398 ts.append(t)
403 399 del ss[:]
404 400 for y in getlist(x[1]):
405 w, t = _optimize(y, False)
401 w, t = _optimize(y)
406 402 if t is not None and (t[0] == 'string' or t[0] == 'symbol'):
407 403 ss.append((w, t))
408 404 continue
@@ -416,35 +412,35 b' def _optimize(x, small):'
416 412 elif op == 'not':
417 413 # Optimize not public() to _notpublic() because we have a fast version
418 414 if _match('public()', x[1]):
419 o = _optimize(_build('_notpublic()'), not small)
415 o = _optimize(_build('_notpublic()'))
420 416 return o[0], o[1]
421 417 else:
422 o = _optimize(x[1], not small)
418 o = _optimize(x[1])
423 419 return o[0], (op, o[1])
424 420 elif op == 'rangeall':
425 return smallbonus, x
421 return 1, x
426 422 elif op in ('rangepre', 'rangepost', 'parentpost'):
427 o = _optimize(x[1], small)
423 o = _optimize(x[1])
428 424 return o[0], (op, o[1])
429 425 elif op in ('dagrange', 'range'):
430 wa, ta = _optimize(x[1], small)
431 wb, tb = _optimize(x[2], small)
426 wa, ta = _optimize(x[1])
427 wb, tb = _optimize(x[2])
432 428 return wa + wb, (op, ta, tb)
433 429 elif op in ('parent', 'ancestor', 'relation', 'subscript'):
434 w, t = _optimize(x[1], small)
430 w, t = _optimize(x[1])
435 431 return w, (op, t, x[2])
436 432 elif op == 'relsubscript':
437 w, t = _optimize(x[1], small)
433 w, t = _optimize(x[1])
438 434 return w, (op, t, x[2], x[3])
439 435 elif op == 'list':
440 ws, ts = zip(*(_optimize(y, small) for y in x[1:]))
436 ws, ts = zip(*(_optimize(y) for y in x[1:]))
441 437 return sum(ws), (op,) + ts
442 438 elif op == 'keyvalue':
443 w, t = _optimize(x[2], small)
439 w, t = _optimize(x[2])
444 440 return w, (op, x[1], t)
445 441 elif op == 'func':
446 442 f = getsymbol(x[1])
447 wa, ta = _optimize(x[2], small)
443 wa, ta = _optimize(x[2])
448 444 if f in ('author', 'branch', 'closed', 'date', 'desc', 'file', 'grep',
449 445 'keyword', 'outgoing', 'user', 'destination'):
450 446 w = 10 # slow
@@ -453,7 +449,7 b' def _optimize(x, small):'
453 449 elif f == "contains":
454 450 w = 100 # very slow
455 451 elif f == "ancestor":
456 w = 1 * smallbonus
452 w = 0.5
457 453 elif f in ('reverse', 'limit', 'first', 'wdir', '_intlist'):
458 454 w = 0
459 455 elif f == "sort":
@@ -468,7 +464,7 b' def optimize(tree):'
468 464
469 465 All pseudo operations should be transformed beforehand.
470 466 """
471 _weight, newtree = _optimize(tree, small=True)
467 _weight, newtree = _optimize(tree)
472 468 return newtree
473 469
474 470 # the set of valid characters for the initial letter of symbols in
General Comments 0
You need to be logged in to leave comments. Login now