]> git.xolatile.top Git - soikk-DB.git/commitdiff
Improved sameStr by removing an unnecessary check
author= <=>
Fri, 6 May 2022 18:44:32 +0000 (20:44 +0200)
committer= <=>
Fri, 6 May 2022 18:44:32 +0000 (20:44 +0200)
TODO
src/main.c
src/storage.c
src/str.c

diff --git a/TODO b/TODO
index 8fb936df6bc269fdac6bf6b2c8af3c6ac31648a7..d133a03dee1b49dbede0a880839b57d1f3f031e8 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1 +1 @@
-Nothing lol
\ No newline at end of file
+DONE   Try to improve 'sameStr' by maybe not having to check s2[i2]
index 636d0b4d1cfb7f40257566b6e903229d4c0aac5c..ddf12ef161908c607d2e1b50376f33dd6d049c22 100644 (file)
@@ -5,26 +5,16 @@ int main(){
 
        inputBuffer *in = newInputBuffer();
 
-
-       row r = {"C:/xd", "", 0, 0};
-       printf("%s %d %d\n", r.tags, r.numTags, r.lenTags);7
-       insertTag(&r, "caca");
-       insertTag(&r, "mierda");
-       insertTag(&r, "caca ");
-       insertTag(&r, "tu");
-       printf("%s %d %d\n", r.tags, r.numTags, r.lenTags);
-
-       printf("%d\n", strInTags(r.tags, r.lenTags, ";perro", 6, ';'));
-
-       row *r2 = newRow("asa");
+       row *r = newRow("~/test/img.png");
 
        while(1){
 
                prompt();
                getInput(in);
                
-               insertTag(r2, in->buffer);
-               printf("Tags of row '%s': %s\n", r2->path, r2->tags);
+               insertTag(r, in->buffer);
+               printf("Tags of row '%s': %s\n", r->path, r->tags);
+               printf("Number of tags: %u. Length of tags: %u\n", r->numTags, r->lenTags);
 
                /*switch(handleInput(in)){
                        case META_COMMAND_SUCCESS:
@@ -35,4 +25,4 @@ int main(){
                                break;
                }*/
        }
-}
\ No newline at end of file
+}
index c9dc5d0de5a1bc715ba7ded4b5e4c96970bfeb3b..9b66132b09f93e45f7cda64373d855cc0d8493e1 100644 (file)
@@ -2,7 +2,6 @@
 
 
 row *newRow(const char path[MAXPATH]){
-       printf("len: %d\n", len(path));
        row *nr = malloc(sizeof(row));
        memcpy(nr->path, path, len(path));
        nr->numTags = 0;
@@ -105,7 +104,6 @@ void insertTag(row *r, char *tag){
                                i = 0;
                                break;
                        case 0:
-                               printf("'%s' == '%s'\n", arr[i-1], arr[i]);
                                // The tag already exists, no need to alter anything
                                free(arr);
                                return;
@@ -168,4 +166,4 @@ void removeTag(row *r, char *tag){
        r->tags[tagnum] = '\0';
        r->numTags = l;
        r->lenTags = tagnum;
-}
\ No newline at end of file
+}
index 9cf5685a8756f813ef88ea9b60f38f67ae9cd5f7..ef2edad8b9c80d176c95f560582c0c5e524cd174 100644 (file)
--- a/src/str.c
+++ b/src/str.c
@@ -9,7 +9,7 @@ uint16_t len(const char *s){
 
 bool sameStr(const char *s1, const char *s2){
        uint16_t i1 = 0, i2 = 0;
-       while(s1[i1] && s2[i2] && s1[i1] == s2[i2])
+       while(s1[i1] && s1[i1] == s2[i2])
                ++i1, ++i2;
        return !s1[i1] && !s2[i2];
 }
@@ -56,4 +56,4 @@ ssize_t strInTags(const char *tags, int n, const char *ndl, int m, char sep){
                }
        }
        return -1;
-}
\ No newline at end of file
+}