Skip to content

Commit

Permalink
Small code optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
paolostivanin committed Nov 16, 2021
1 parent 88e18dd commit 15e84fa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(OTPClient VERSION "2.4.4" LANGUAGES "C")
project(OTPClient VERSION "2.4.7" LANGUAGES "C")

configure_file("src/common/version.h.in" "version.h")
include_directories(${PROJECT_BINARY_DIR})
Expand Down
9 changes: 9 additions & 0 deletions data/com.github.paolostivanin.OTPClient.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ It's also possible to import/export backups from/to andOTP and import backups fr
</content_rating>

<releases>
<release version="2.4.7" date="2021-11-16">
<description>
<p>OTPClient 2.4.7 implements some small code optimization</p>
<ul>
<li>do not use strlen in for loop</li>
<li>do not use strlen to check for empty string</li>
</ul>
</description>
</release>
<release version="2.4.6" date="2021-11-15">
<description>
<p>OTPClient 2.4.6 fixes some small issues</p>
Expand Down
2 changes: 1 addition & 1 deletion src/add-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ check_params (GSList *otps)
return g_strdup ("Label can not be empty, otp not imported");
}

if (strlen (otp->secret) == 0) {
if (otp->secret[0] == '\0') {
return g_strdup ("Secret can not be empty, otp not imported");
}

Expand Down
6 changes: 4 additions & 2 deletions src/parse-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ is_input_valid (GtkWidget *dialog,
static gboolean
str_is_only_num_or_alpha (const gchar *string)
{
for (gint i = 0; i < strlen (string); i++) {
size_t s_len = strlen (string);
for (gint i = 0; i < s_len; i++) {
if (!g_ascii_isalnum (string[i])) {
return FALSE;
}
Expand All @@ -136,7 +137,8 @@ str_is_only_num_or_alpha (const gchar *string)
static gboolean
str_is_only_num (const gchar *string)
{
for (gint i = 0; i < strlen (string); i++) {
size_t s_len = strlen (string);
for (gint i = 0; i < s_len; i++) {
if (!g_ascii_isdigit (string[i])) {
return FALSE;
}
Expand Down

0 comments on commit 15e84fa

Please sign in to comment.