chuckcarpenter/REM-unit-polyfill — pull request #44 by muchabi (2014-03-30 02:15:39+00:00)
Title: Convert 'removeComments' from recursive implementation to while loop (no...

... risk of stack overflow for large files)

I added the polyfill to a Rails4/Foundation5 project, in which the generated CSS file had a large number of comments. These were development environment comments that were put in to help trace the rule back to its source file, for example:

```
/* line 324, /Users/fenix/.rvm/gems/ruby-2.0.0-p195/gems/foundation-rails-5.2.1.0/vendor/assets/stylesheets/foundation/components/_visibility.scss */
.touch table.show-for-touch {
display: table;
}

/* line 325, /Users/fenix/.rvm/gems/ruby-2.0.0-p195/gems/foundation-rails-5.2.1.0/vendor/assets/stylesheets/foundation/components/_visibility.scss */
thead.hide-for-touch {
display: table-header-group !important;
}
```

Because there were so many of these comments, a stack overflow occurred within the removeComments function, which used to be implemented recursively.

I replaced the recursive implementation with a while loop, and the stack overflow stopped occurring.