{"id":8308,"date":"2014-01-10T16:19:36","date_gmt":"2014-01-10T21:19:36","guid":{"rendered":"http:\/\/mjtsai.com\/blog\/?p=8308"},"modified":"2014-01-10T16:19:36","modified_gmt":"2014-01-10T21:19:36","slug":"why-gnu-grep-is-fast","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2014\/01\/10\/why-gnu-grep-is-fast\/","title":{"rendered":"Why GNU grep Is Fast"},"content":{"rendered":"<p><a href=\"http:\/\/lists.freebsd.org\/pipermail\/freebsd-current\/2010-August\/019310.html\">Mike Haertel<\/a>:<\/p>\n<blockquote cite=\"http:\/\/lists.freebsd.org\/pipermail\/freebsd-current\/2010-August\/019310.html\"><p>Moreover, GNU grep AVOIDS BREAKING THE INPUT INTO LINES.  Looking\nfor newlines would slow grep down by a factor of several times,\nbecause to find the newlines it would have to look at every byte!<\/p>\n<p>So instead of using line-oriented input, GNU grep reads raw data into\na large buffer, searches the buffer using Boyer-Moore, and only when\nit finds a match does it go and look for the bounding newlines.\n(Certain command line options like -n disable this optimization.)<\/p><\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Mike Haertel: Moreover, GNU grep AVOIDS BREAKING THE INPUT INTO LINES. Looking for newlines would slow grep down by a factor of several times, because to find the newlines it would have to look at every byte! So instead of using line-oriented input, GNU grep reads raw data into a large buffer, searches the buffer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[719,138,71,163],"class_list":["post-8308","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-grep","tag-optimization","tag-programming","tag-unix"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=8308"}],"version-history":[{"count":0,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/8308\/revisions"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=8308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=8308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=8308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}