Permalink
Browse files

Fix a Rails perf issue.

Closes #124.
  • Loading branch information...
1 parent 78c02f9 commit 527e2f4a0dd849b89faf0a9d661bd7814d0ab95b @nex3 nex3 committed Aug 21, 2012
@@ -3,6 +3,11 @@
* Table of contents
{:toc}
+## 3.2.2 (Unreleased)
+
+* Fix a performance issue with `@import` that only appears when
+ ActiveSupport is loaded.
+
## 3.2.1 (15 August 2012)
* Fix a buggy interaction with Pow and Capybara that caused `EOFError`s.
@@ -28,7 +28,7 @@ def find(name, options)
# @see Base#mtime
def mtime(name, options)
- file, s = find_real_file(@root, name)
+ file, s = Sass::Util.destructure(find_real_file(@root, name))
File.mtime(file) if file
rescue Errno::ENOENT
nil
@@ -132,7 +132,7 @@ def split(name)
private
def _find(dir, name, options)
- full_filename, syntax = find_real_file(dir, name)
+ full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name))
return unless full_filename && File.readable?(full_filename)
options[:syntax] = syntax
@@ -140,7 +140,7 @@ def mtime(uri, importer)
end
def dependencies(uri, importer)
- stored_mtime, dependencies = @dependencies[[uri, importer]]
+ stored_mtime, dependencies = Sass::Util.destructure(@dependencies[[uri, importer]])
if !stored_mtime || stored_mtime < mtime(uri, importer)
dependencies = compute_dependencies(uri, importer)
View
@@ -706,7 +706,7 @@ def placeholder_selector
end
def element_name
- ns, name = qualified_name(:allow_star_name)
+ ns, name = Sass::Util.destructure(qualified_name(:allow_star_name))
return unless ns || name
if name == '*'
@@ -797,7 +797,7 @@ def pseudo_arg
# could start a pseudo expression like "n+1", or it could start a
# selector like "n|m". In order to handle this, we must regrettably
# backtrack.
- expr, sel = nil
+ expr, sel = nil, nil
pseudo_err = catch_error do
expr = pseudo_expr
next if tok?(/[,)]/)
View
@@ -467,6 +467,19 @@ def glob(path, &block)
Dir.glob(path, &block)
end
+ # Prepare a value for a destructuring assignment (e.g. `a, b =
+ # val`). This works around a performance bug when using
+ # ActiveSupport, and only needs to be called when `val` is likely
+ # to be `nil` reasonably often.
+ #
+ # See [this bug report](http://redmine.ruby-lang.org/issues/4917).
+ #
+ # @param val [Object]
+ # @return [Object]
+ def destructure(val)
+ val || []
+ end
+
## Cross-Ruby-Version Compatibility
# Whether or not this is running under Ruby 1.8 or lower.

0 comments on commit 527e2f4

Please sign in to comment.