{"id":52,"date":"2024-07-06T16:26:33","date_gmt":"2024-07-06T16:26:33","guid":{"rendered":"https:\/\/blogs.scummvm.org\/chico\/?p=52"},"modified":"2024-07-06T16:26:33","modified_gmt":"2024-07-06T16:26:33","slug":"week6-refinement","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/chico\/2024\/07\/06\/week6-refinement\/","title":{"rendered":"Week6 &#8211; Refinement"},"content":{"rendered":"<p>This week\u2019s work went relatively smoothly, and I encountered nothing too challenging. At the beginning of the week, sev reminded me that my original regex was matching too slowly. I reviewed the code and realized I had fallen into an <a href=\"https:\/\/en.wikipedia.org\/wiki\/XY_problem\">X-Y problem<\/a> myself.<\/p>\n<p>That is, I was focused on using regex to solve the string-matching problem, but I overlooked the fact that using an extra regex might not be necessary at all. My current expression can indeed match all the cases in the existing dat files, but the problem is that it\u2019s not necessary to do so. Since the structure within each \u201crom\u201d section is fixed and different blocks are always separated by a space, token matching is sufficient. There\u2019s no need to use a complex regex to cover all edge cases, and the performance will be much better (linear time complexity).<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-53\" src=\"https:\/\/blogs.scummvm.org\/chico\/wp-content\/uploads\/sites\/74\/2024\/07\/IBX9W4V5KQG40S7P7@PWD-300x79.png\" alt=\"\" width=\"641\" height=\"169\" srcset=\"https:\/\/blogs.scummvm.org\/chico\/wp-content\/uploads\/sites\/74\/2024\/07\/IBX9W4V5KQG40S7P7@PWD-300x79.png 300w, https:\/\/blogs.scummvm.org\/chico\/wp-content\/uploads\/sites\/74\/2024\/07\/IBX9W4V5KQG40S7P7@PWD-1024x271.png 1024w, https:\/\/blogs.scummvm.org\/chico\/wp-content\/uploads\/sites\/74\/2024\/07\/IBX9W4V5KQG40S7P7@PWD-768x203.png 768w, https:\/\/blogs.scummvm.org\/chico\/wp-content\/uploads\/sites\/74\/2024\/07\/IBX9W4V5KQG40S7P7@PWD-1536x407.png 1536w, https:\/\/blogs.scummvm.org\/chico\/wp-content\/uploads\/sites\/74\/2024\/07\/IBX9W4V5KQG40S7P7@PWD-2048x542.png 2048w, https:\/\/blogs.scummvm.org\/chico\/wp-content\/uploads\/sites\/74\/2024\/07\/IBX9W4V5KQG40S7P7@PWD-1200x318.png 1200w, https:\/\/blogs.scummvm.org\/chico\/wp-content\/uploads\/sites\/74\/2024\/07\/IBX9W4V5KQG40S7P7@PWD-1980x524.png 1980w\" sizes=\"auto, (max-width: 641px) 100vw, 641px\" \/><\/p>\n<p>As planned last week, I added a <code>detection_type<\/code> column to the file table. This makes it clearer when recalculating the megakey.<\/p>\n<p>Due to the addition of the <code>detection_type<\/code> column and <code>set.dat<\/code> , the code logic requires some extra handling. Therefore, I also refactored the original code, decoupling the matching-related code through modularization to facilitate future development and expansion.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week\u2019s work went relatively smoothly, and I encountered nothing too challenging. At the beginning of the week, sev reminded me that my original regex was matching too slowly. I reviewed the code and realized I had fallen into an X-Y problem myself. That is, I was focused on using regex to solve the string-matching [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-cli"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":1,"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/posts\/52\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/chico\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}