refs: Don't try searching for input strings that can't be objects
I noticed OSTree was a bit slower, did some investigation and saw we were enumerating all objects for things like $ ostree rev-parse blah Since "blah" can never be an object (because of the 'l' and 'h'), just return no matches.
This commit is contained in:
parent
9bd229dff5
commit
d5e813c52c
|
|
@ -364,6 +364,8 @@ ostree_repo_resolve_partial_checksum (OstreeRepo *self,
|
|||
GError **error)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
static const char hexchars[] = "0123456789abcdef";
|
||||
gsize off;
|
||||
gs_unref_hashtable GHashTable *ref_list = NULL;
|
||||
gs_free char *ret_rev = NULL;
|
||||
guint length;
|
||||
|
|
@ -375,6 +377,12 @@ ostree_repo_resolve_partial_checksum (OstreeRepo *self,
|
|||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
/* If the input is longer than 64 chars or contains non-hex chars,
|
||||
don't bother looking for it as an object */
|
||||
off = strspn (refspec, hexchars);
|
||||
if (off > 64 || refspec[off] != '\0')
|
||||
return TRUE;
|
||||
|
||||
/* this looks through all objects and adds them to the ref_list if:
|
||||
a) they are a commit object AND
|
||||
b) the obj checksum starts with the partual checksum defined by "refspec" */
|
||||
|
|
|
|||
Loading…
Reference in New Issue