From 01bf5c7970b3d7cb872902f5a5298b489da3defb Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 27 Nov 2008 19:35:55 -0500 Subject: Optimized bug loading from becommands/comment with partial-uuid matching. The code is a bit uglier now, but it's a good deal faster :). --- becommands/comment.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'becommands/comment.py') diff --git a/becommands/comment.py b/becommands/comment.py index 8fdbe42..5000588 100644 --- a/becommands/comment.py +++ b/becommands/comment.py @@ -122,12 +122,20 @@ def complete(options, args, parser): for pos,value in enumerate(args): if value == "--complete": if pos == 0: # fist positional argument is a bug or comment id + if len(args) >= 2: + partial = args[1].split(':')[0] # take only bugid portion + else: + partial = "" ids = [] try: bd = bugdir.BugDir(from_disk=True, manipulate_encodings=False) - bd.load_all_bugs() - bugs = [bug for bug in bd if bug.active == True] + bugs = [] + for uuid in bd.list_uuids(): + if uuid.startswith(partial): + bug = bd.bug_from_uuid(uuid) + if bug.active == True: + bugs.append(bug) for bug in bugs: shortname = bd.bug_shortname(bug) ids.append(shortname) -- cgit