From cdf6fb4a221a65cca949f3c8431a8700f6f5e1be Mon Sep 17 00:00:00 2001 From: Ted Nyman Date: Sun, 29 Dec 2013 02:54:15 -0800 Subject: [PATCH] Initialize breakdown hash --- README.md | 2 +- lib/linguist/repository.rb | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c49d52dc..56ba5192 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ We use this library at GitHub to detect blob languages, highlight code, ignore b ### Language detection -Linguist defines the list of all languages known to GitHub in a [yaml file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). In order for a file to be highlighted, a language and lexer must be defined there. +Linguist defines a list of all languages known to GitHub in a [yaml file](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). In order for a file to be highlighted, a language and lexer must be defined there. Most languages are detected by their file extension. This is the fastest and most common situation. diff --git a/lib/linguist/repository.rb b/lib/linguist/repository.rb index 180ed679..a62bf281 100644 --- a/lib/linguist/repository.rb +++ b/lib/linguist/repository.rb @@ -29,7 +29,7 @@ module Linguist @computed_stats = false @language = @size = nil @sizes = Hash.new { 0 } - @file_breakdown = {} + @file_breakdown = Hash.new { |h,k| h[k] = Array.new } end # Public: Returns a breakdown of language stats. @@ -83,12 +83,8 @@ module Linguist # Only include programming languages and acceptable markup languages if blob.language.type == :programming || Language.detectable_markup.include?(blob.language.name) - # Build up the per-file breakdown stats if asked - if @file_breakdown[blob.language.group.name] - @file_breakdown[blob.language.group.name] << blob.name - else - @file_breakdown[blob.language.group.name] = [blob.name] - end + # Build up the per-file breakdown stats + @file_breakdown[blob.language.group.name] << blob.name @sizes[blob.language.group] += blob.size end