{"id":26436,"date":"2019-08-30T17:28:44","date_gmt":"2019-08-30T21:28:44","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=26436"},"modified":"2019-08-30T17:28:44","modified_gmt":"2019-08-30T21:28:44","slug":"accidentally-quadratic-constant-folding","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2019\/08\/30\/accidentally-quadratic-constant-folding\/","title":{"rendered":"Accidentally Quadratic Constant Folding"},"content":{"rendered":"<p><a href=\"https:\/\/accidentallyquadratic.tumblr.com\/post\/187336866277\/accidentally-quadratic-constant-folding\">Neal Gafter<\/a>:<\/p>\n<blockquote cite=\"https:\/\/accidentallyquadratic.tumblr.com\/post\/187336866277\/accidentally-quadratic-constant-folding\">\n<p>Fixing the problem was fairly straightforward, using a technique I learned from the Cedar\/Mesa compiler in the early &rsquo;80s. Rather than representing string constants in the compilers using strings, they are now represented using a data structure called&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Rope_(data_structure)\">Ropes<\/a>. Concatenating two ropes requires only a small constant amount of memory.<\/p>\n<p>Any compiler for a language that supports constant folding of string concatenation will run into this problem unless there is a similarly low-space representation of two concatenated strings. This is a technique that should be in the bag of tricks of any compiler writer.<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Neal Gafter: Fixing the problem was fairly straightforward, using a technique I learned from the Cedar\/Mesa compiler in the early &rsquo;80s. Rather than representing string constants in the compilers using strings, they are now represented using a data structure called&nbsp;Ropes. Concatenating two ropes requires only a small constant amount of memory. Any compiler for a [&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":"2019-08-30T21:28:47Z","apple_news_api_id":"71aad094-c6d4-496a-aa3d-cb2569131c37","apple_news_api_modified_at":"2019-08-30T21:28:48Z","apple_news_api_revision":"AAAAAAAAAAD\/\/\/\/\/\/\/\/\/\/w==","apple_news_api_share_url":"https:\/\/apple.news\/AcarQlMbUSWqqPcslaRMcNw","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":[351,255,138,71],"class_list":["post-26436","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-c-sharp","tag-compiler","tag-optimization","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26436","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=26436"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26436\/revisions"}],"predecessor-version":[{"id":26437,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/26436\/revisions\/26437"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=26436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=26436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=26436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}