summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-08-25 23:21:27 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-08-29 06:49:44 -0700
commit456e2cec89bf53904851cce2bad7f344c64c6f98 (patch)
tree12c8dacfd0da586d6e5cd8ef5875a8c82ff023b7 /core/qthelper.cpp
parent515b7b5fea13762f8003963eca4c2a241c52dfb7 (diff)
downloadsubsurface-456e2cec89bf53904851cce2bad7f344c64c6f98.tar.gz
Cache all Buehlmann factors
not just the last one. Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index b9698e6b8..e6a4e056a 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -1710,3 +1710,21 @@ char *intdup(int index)
tmpbuf[20] = 0;
return strdup(tmpbuf);
}
+
+QHash<int, double> factor_cache;
+
+extern "C" double cache_value(int tissue, int timestep, enum inertgas inertgas)
+{
+ int key = (timestep << 5) + (tissue << 1);
+ if (inertgas == HE)
+ ++key;
+ return factor_cache.value(key);
+}
+
+extern "C" void cache_insert(int tissue, int timestep, enum inertgas inertgas, double value)
+{
+ int key = (timestep << 5) + (tissue << 1);
+ if (inertgas == HE)
+ ++key;
+ factor_cache.insert(key, value);
+}