diff --git a/COMPTE_RENDU.md b/COMPTE_RENDU.md index 386ef5d..cb6c179 100644 --- a/COMPTE_RENDU.md +++ b/COMPTE_RENDU.md @@ -102,7 +102,7 @@ La complexité de la fonction est de [O(n)] pour - Optimisation de la fonction 9 nom du commit : "". Emprunte : ff68d260a7a58441 -- Optimisation de la fonction 10 nom du commit : "". Emprunte : ff68d260a7a58441 +- Optimisation de la fonction 10 nom du commit : "fonction 10 : O(L)". Emprunte : ff68d260a7a58441 diff --git a/banque b/banque index c983cc0..25e045c 100755 Binary files a/banque and b/banque differ diff --git a/banque.c b/banque.c index 0b1aa36..5a48147 100644 --- a/banque.c +++ b/banque.c @@ -235,10 +235,16 @@ int categorie(const Transaction *t) /* F10 : ajoute une ligne à la fin du rapport */ int longueur(const char *s) { - int n = 0; - while (s[n] != '\0') - n++; - return n; + static const char *chaine_connue = NULL; + static int n_connu = 0; + + if (s != chaine_connue || s[0] == '\0') { + chaine_connue = s; + n_connu = 0; + } + while (s[n_connu] != '\0') + n_connu++; + return n_connu; } void ajouter_ligne(char *rapport, const char *ligne)