diff options
author | lloyd <[email protected]> | 2008-11-11 18:18:03 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-11-11 18:18:03 +0000 |
commit | 1befa604ad62332aab1729d023c89556e63332c7 (patch) | |
tree | fa0746f956f414d0e844f6711e7762e2e5a1d9fb /src/algo_factory/algo_factory.cpp | |
parent | 237258e42f4b1b8c01d91518270c4a9c59a0dc47 (diff) |
Fix algo_cache to track aliases, all tests pass
Diffstat (limited to 'src/algo_factory/algo_factory.cpp')
-rw-r--r-- | src/algo_factory/algo_factory.cpp | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/src/algo_factory/algo_factory.cpp b/src/algo_factory/algo_factory.cpp index 1f49a0d48..4f137d636 100644 --- a/src/algo_factory/algo_factory.cpp +++ b/src/algo_factory/algo_factory.cpp @@ -178,47 +178,24 @@ void Algorithm_Factory::add_stream_cipher(StreamCipher* hash) } /** -* Return the prototypical object cooresponding to this request +* Return the prototypical object cooresponding to this request (if found) */ const HashFunction* Algorithm_Factory::prototype_hash_function(const SCAN_Name& request) { -#if 1 - for(u32bit i = 0; i != engines.size(); ++i) - { - if(request.provider_allowed(engines[i]->provider_name())) - { - const HashFunction* algo = - engines[i]->prototype_hash_function(request, *this); - - if(algo) - return algo; - } - } - - return 0; -#else const HashFunction* cache_hit = hash_cache.get(request); if(cache_hit) return cache_hit; - // Search for all providers of this algorithm and add them to the cache for(u32bit i = 0; i != engines.size(); ++i) { - const std::string provider = engines[i]->provider_name(); - HashFunction* impl = engines[i]->find_hash(request, *this); - - if(impl) - hash_cache.add(impl, provider); + if(HashFunction* impl = engines[i]->find_hash(request, *this)) + { + hash_cache.add(impl, request.as_string(), engines[i]->provider_name()); + } } - /* Now try the cache search again (if the providers don't match up - with ones that exist in this build, this might still fail and - return 0). - */ - return hash_cache.get(request); -#endif } /** |