-
-
Save presidentbeef/7156955 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby -w | |
require 'set' | |
Entry = Struct.new :id, :instance do | |
def self.parse(line) | |
if /ID=\s*'([^']*)'\s+INSTANCE=\s*'([^']*)'/ =~ line | |
new $1, $2 | |
else | |
raise "Cannot parse: %p" % line | |
end | |
end | |
end | |
entries = Set.new | |
ARGV.each do |file| | |
File.foreach file do |line| | |
begin | |
entry = Entry.parse(line) | |
if entries.include? entry | |
puts line | |
else | |
entries << entry | |
end | |
rescue | |
# Ignore lines that don't parse | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And with Robert's original:
So no memory savings, but faster.