diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-07-28 02:36:01 +0200 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2010-07-28 02:36:01 +0200 |
commit | 6c59a7213763dfe2859c7cfe6683711700fda978 (patch) | |
tree | 6a6d13cc12fbf2c83d855cb6ac3e4f61706b2ba0 /ncr-limits.c | |
parent | 98402c1ba577d4fd8940d19cd4f6b79c3d105380 (diff) | |
download | cryptodev-linux-6c59a7213763dfe2859c7cfe6683711700fda978.tar.gz cryptodev-linux-6c59a7213763dfe2859c7cfe6683711700fda978.tar.xz cryptodev-linux-6c59a7213763dfe2859c7cfe6683711700fda978.zip |
Stop looking in the hash table after the first match.
There should be only one entry anyway. This reduces the average lookup
time when there are hash collisions roughly by half.
Diffstat (limited to 'ncr-limits.c')
-rw-r--r-- | ncr-limits.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ncr-limits.c b/ncr-limits.c index 3dcb9cc..4d36c4f 100644 --- a/ncr-limits.c +++ b/ncr-limits.c @@ -140,6 +140,7 @@ int ret; mutex_unlock(&user_limit_mutex); return -EPERM; } + break; } } @@ -175,6 +176,7 @@ int ret; ret = -EPERM; goto restore_user; } + break; } } @@ -203,8 +205,10 @@ int ret; restore_user: mutex_lock(&user_limit_mutex); hlist_for_each_entry(uitem, pos, user_head, hlist) { - if (uitem->uid == uid) + if (uitem->uid == uid) { atomic_dec(&uitem->cnt[type]); + break; + } } mutex_unlock(&user_limit_mutex); return ret; @@ -223,6 +227,7 @@ struct hlist_node *pos; hlist_for_each_entry(uitem, pos, hhead, hlist) { if (uitem->uid == uid) { atomic_dec(&uitem->cnt[type]); + break; } } mutex_unlock(&user_limit_mutex); @@ -233,6 +238,7 @@ struct hlist_node *pos; hlist_for_each_entry(pitem, pos, hhead, hlist) { if (pitem->pid == pid) { atomic_dec(&pitem->cnt[type]); + break; } } mutex_unlock(&process_limit_mutex); |