From a605ad3a0a7fbc442b0c0bc98bd7c21a04650127 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 24 Mar 2008 16:16:15 +0000 Subject: [PATCH] Cache the parsed hexdumps so that each dump file is only parsed once. git-svn-id: http://lm-sensors.org/svn/i2c-tools/trunk@5161 7894878c-1315-0410-8ee3-d5d059ff63e0 --- eeprom/decode-dimms.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eeprom/decode-dimms.pl b/eeprom/decode-dimms.pl index 650f277..39ea3cd 100755 --- a/eeprom/decode-dimms.pl +++ b/eeprom/decode-dimms.pl @@ -40,7 +40,7 @@ use strict; use POSIX; use Fcntl qw(:DEFAULT :seek); use vars qw($opt_html $opt_bodyonly $opt_igncheck $use_sysfs $use_hexdump - @vendors %decode_callback $revision @dimm_list); + @vendors %decode_callback $revision @dimm_list %hexdump_cache); $revision = '$Revision$ ($Date$)'; $revision =~ s/\$\w+: (.*?) \$/$1/g; @@ -1104,6 +1104,9 @@ sub read_hexdump($) my $header = 1; my $word = 0; + # Look in the cache first + return @{$hexdump_cache{$_[0]}} if exists $hexdump_cache{$_[0]}; + open F, '<', $_[0] or die "Unable to open: $_[0]"; while () { chomp; @@ -1138,6 +1141,9 @@ sub read_hexdump($) close F; $header and die "Unable to parse any data from hexdump '$_[0]'"; $word and printc "Warning: Assuming big-endian order 16-bit hex dump"; + + # Cache the data for later use + $hexdump_cache{$_[0]} = \@bytes; return @bytes; }