[f-spot] Check for existance of the key in cache dictionary first.
- From: Ruben Vermeersch <rubenv src gnome org>
- To: svn-commits-list gnome org
- Subject: [f-spot] Check for existance of the key in cache dictionary first.
- Date: Mon, 25 May 2009 08:10:17 -0400 (EDT)
commit 105298b8f0f2f16d9ef77a35b4bbd90f2fee54b4
Author: Ruben Vermeersch <ruben savanne be>
Date: Mon May 25 14:07:49 2009 +0200
Check for existance of the key in cache dictionary first.
Hashtable returned null, Dictionary throws an exception.
---
src/Db.cs | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/Db.cs b/src/Db.cs
index 750fc88..5ad854f 100644
--- a/src/Db.cs
+++ b/src/Db.cs
@@ -39,14 +39,14 @@ public abstract class DbStore<T> where T : DbItem {
protected T LookupInCache (uint id)
{
+ if (!item_cache.ContainsKey(id))
+ return null;
+
if (cache_is_immortal)
return item_cache [id] as T;
WeakReference weakref = item_cache [id] as WeakReference;
- if (weakref == null)
- return null;
- else
- return (T) weakref.Target;
+ return (T) weakref.Target;
}
protected void RemoveFromCache (T item)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]