aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-05-27 16:41:24 +0000
committerlloyd <[email protected]>2006-05-27 16:41:24 +0000
commitc4204430b1c050c54a464b677c4a90a785542b1a (patch)
tree980cffcf93a8b74cac0ee155faa6e95fd594739b
parenta5c9bc9588c21d97ae66ca56c0198f91d134a7fd (diff)
Use .empty() instead of comparing .size() to 0 in a few cases, and
reorder an if statement for better readability.
-rw-r--r--src/def_alg.cpp12
-rw-r--r--src/der_enc.cpp9
2 files changed, 11 insertions, 10 deletions
diff --git a/src/def_alg.cpp b/src/def_alg.cpp
index 9b87f6c2a..9b24e07c1 100644
--- a/src/def_alg.cpp
+++ b/src/def_alg.cpp
@@ -110,7 +110,7 @@ BlockCipher*
Default_Engine::find_block_cipher(const std::string& algo_spec) const
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- if(name.size() == 0)
+ if(name.empty())
return 0;
const std::string algo_name = deref_alias(name[0]);
@@ -158,7 +158,7 @@ StreamCipher*
Default_Engine::find_stream_cipher(const std::string& algo_spec) const
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- if(name.size() == 0)
+ if(name.empty())
return 0;
const std::string algo_name = deref_alias(name[0]);
@@ -177,7 +177,7 @@ HashFunction*
Default_Engine::find_hash(const std::string& algo_spec) const
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- if(name.size() == 0)
+ if(name.empty())
return 0;
const std::string algo_name = deref_alias(name[0]);
@@ -215,7 +215,7 @@ MessageAuthenticationCode*
Default_Engine::find_mac(const std::string& algo_spec) const
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- if(name.size() == 0)
+ if(name.empty())
return 0;
const std::string algo_name = deref_alias(name[0]);
@@ -232,7 +232,7 @@ Default_Engine::find_mac(const std::string& algo_spec) const
S2K* Default_Engine::find_s2k(const std::string& algo_spec) const
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- if(name.size() == 0)
+ if(name.empty())
return 0;
const std::string algo_name = deref_alias(name[0]);
@@ -251,7 +251,7 @@ BlockCipherModePaddingMethod*
Default_Engine::find_bc_pad(const std::string& algo_spec) const
{
std::vector<std::string> name = parse_algorithm_name(algo_spec);
- if(name.size() == 0)
+ if(name.empty())
return 0;
const std::string algo_name = deref_alias(name[0]);
diff --git a/src/der_enc.cpp b/src/der_enc.cpp
index a3d61152b..b389d5694 100644
--- a/src/der_enc.cpp
+++ b/src/der_enc.cpp
@@ -171,7 +171,7 @@ DER_Encoder& DER_Encoder::start_cons(ASN1_Tag type_tag,
*************************************************/
DER_Encoder& DER_Encoder::end_cons()
{
- if(subsequences.size() == 0)
+ if(subsequences.empty())
throw Invalid_State("DER_Encoder::end_cons: No such sequence");
SecureVector<byte> seq = subsequences[subsequences.size()-1].get_contents();
@@ -214,10 +214,11 @@ DER_Encoder& DER_Encoder::raw_bytes(const MemoryRegion<byte>& val)
*************************************************/
DER_Encoder& DER_Encoder::raw_bytes(const byte bytes[], u32bit length)
{
- if(subsequences.size() == 0)
- contents.append(bytes, length);
- else
+ if(subsequences.size())
subsequences[subsequences.size()-1].add_bytes(bytes, length);
+ else
+ contents.append(bytes, length);
+
return (*this);
}