From 6be2d372f2bd26e11aad22c01ae67850a5813228 Mon Sep 17 00:00:00 2001 From: retoor Date: Sun, 1 Dec 2024 19:40:01 +0100 Subject: [PATCH] A few optimizations. --- isspam | Bin 33312 -> 33312 bytes retoor_c/isspam.c | 41 ++++++++++++++++------------------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/isspam b/isspam index 37029aad7d45889dd466433f9cc526bd57ede09c..4e85c07d49ad11fa871713ef503b6014d23bf852 100755 GIT binary patch delta 3180 zcmZ`*eNPPKj_#3&#hv9X#qRb0ti z+Vk?dYCBDvlMfFyCh=6$)4C18G)00a)|`4$wWje4s~M&15qc2`zUvVZKI zH}~G(@7_Bzcc#gwH2IX@+2q&-lO*w55Ev#`D2&Jl|RDjN!blHZ`SKlHBG3J25A=tF7gd@9c(YY%c)aMxSP83B9Ja zUMjj3Q)SyQlx1B6mnjui{?$isDnZ_@#oGh zv8~@pFtic9BYA0g!Low#g5?DjhlrW4yAZ2C(P@{YRz(EFu7jXAHAtV!dSdSBe}K%t zNG3)XE5*Fq=oBgbBAg<;MT$boj&DP%&E?V&iKkJ?K7fnIxU2ay*V^e{vqsB1=(Q{@ zk!A_fspx76m%&ZH|Qs&ht!l(;E&pm@(9 z^xi$lzG}yR)v!OtIbGk!jOG(HW)mZihx)HM#MNIvVCc= z$nQN^$W`jP#Ka-u`xX9;eCr`oN$2e394itUR%ScM2W%Ec;C-ee2=3r^R^-Z&Es<^?x)6VrmTO!UlAVG>11EP$P*!zL7DD@FtT>?<4- zK(h&6pEMRrUqnmq4}#4JN^ zJ>+U*KSz99^DAL4sg0|6XF_*8e>LO?o5RF7!iHe~pzx^l3W2X%OSxnlIRWh7yeZ)K z+q_Zu=rF*aBJeFC{QDMh=Gm4<@PEr9_}q}M!<8pF{>TRj#PFW&hZ1Q`*yH&638_;qN`AdTMOhD4aOg-!Mdlas=P-==!zJ7LW>p*bKlMdGG!`~&#W zkl77f*BVaQRq+n!Vm;zJ$j%9QnVsVEdgih)Qn8ST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-?S#6YhK_nrvoa$xVofnFueLjKg^-lh5jNd-21Nvb>W;!*LX8-pD3ZmIh z2`Q%@fJEXkedrfXt-`63DrVUCz=#;b?_Kf>)|OI?O;|gF{q%H(1xmM=-@Cv*om3!C zVRt7D4P{_gHBtva1ob-s?V62ew+oU%Jw1Vx+98{&r~Z(M?jK4Tt;G@4`J-pO1zMDS zGCDhY)+TH_wo*eI-d8R4pcwTM-7RJKJ>P7#Hv4*C_R*7L zLLOMx&XnCvdU6()d@f86i~s{Z04r5LB=XwSTV&#eg@k3K>IlPK0J( ziV-57?~p$xCI(=Y%YhpK=kXRSrTMs6ZnSr2NRmkKdGLtNm{zQ#cbK3hurcMJkRNdZ|A*Dzdo>Tqd+m-YAP!Pf_P-|2F*_+koq}YBw!*=FO z59M3#_994Leg@bSoNxY#SY*HHz)OS%p=!)@;KE}bjsmA@@6BIPL)DZ)hbzb{u33&4 z&4*O|Fnj#^_@CL_yW#AJ#v zSrFlXmt^Loh-Qe;_=U!gxzeQ6>;^tHKsDaybWCf+w?-#_MLe5)iIA6hDeY^SJl)Fk zn2>k}mt`zc$Hk|k`Or-@bQ08lnAbTy!@A?dNzS6pe_W5PLKIDZEkb!=ntSlj-1wy-!kA&@}-7Gwdv zrT&ZJmle68e%ibReQh(Ru(uaC$_?zrB_G(5rZU^o`SLNgaA}HM$JQ?WKz@adT=u%W tt^Si`DRH(^H~XyO54JM7{@=e*wKm1QY-O diff --git a/retoor_c/isspam.c b/retoor_c/isspam.c index f91d387..2907e89 100644 --- a/retoor_c/isspam.c +++ b/retoor_c/isspam.c @@ -174,22 +174,14 @@ bool is_fully_capitalized_word(char *word) { return true; } -sl *get_capitalized_words(char *content) { +sl *get_capitalized_words(sl *all_words) { sl *capitalized_words = sln(); - sl *sentences = get_sentences(content); - for (uint j = 0; j < sentences->count; j++) { - char *sentence = sentences->strings[j]; - sl *all_words = get_words(sentence); - - // Always skip the first word since sentences start with for (uint i = 0; i < all_words->count; i++) { if (is_fully_capitalized_word(all_words->strings[i])) { rstring_list_add(capitalized_words, all_words->strings[i]); } } - slf(all_words); - } - slf(sentences); + return capitalized_words; } @@ -251,16 +243,13 @@ bool containswordi(sl *words, char *word) { return false; } -sl *get_forbidden_words(char *content) { - sl *words = get_words(content); +sl *get_forbidden_words(sl *words) { sl *found = sln(); for (int j = 0; forbidden_words[j] != NULL; j++) { if (containswordi(words, forbidden_words[j])) { rstring_list_add(found, forbidden_words[j]); } } - - slf(words); return found; } unsigned int total = 0; @@ -278,8 +267,18 @@ void analyze(FILE *f) { free(clean_data); + sl *words = get_words(data); + + // All words + printf("Words: %llu\n", words->count); + if(show_words) + sld(words); + sbuf = slds(words); + stra(all, sbuf); + free(sbuf); + // All capitalized words - sl *capitalized_words = get_capitalized_words(data); + sl *capitalized_words = get_capitalized_words(words); ulonglong capitalized_words_count = capitalized_words->count; printf("Capitalized words: %llu\n", capitalized_words_count); if(show_capitalized) @@ -298,15 +297,7 @@ void analyze(FILE *f) { stra(all, sbuf); free(sbuf); - sl *words = get_words(data); - - // All words - printf("Words: %llu\n", words->count); - if(show_words) - sld(words); - sbuf = slds(words); - stra(all, sbuf); - free(sbuf); + // Numbers sl *numbers = get_numbers(data); @@ -318,7 +309,7 @@ void analyze(FILE *f) { free(sbuf); // Forbidden words - sl *fw = get_forbidden_words(data); + sl *fw = get_forbidden_words(words); printf("Forbidden words: %llu\n", fw->count); if(show_forbidden_words) sld(fw);