diff options
author | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-10-11 12:44:35 +0000 |
---|---|---|
committer | tradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2005-10-11 12:44:35 +0000 |
commit | 83f469deb9369f71f3c5bccb9ce89dce070b22b2 (patch) | |
tree | 62585a0998dd151072b7d81d04ec39eaaf034f24 /lib/sbin | |
parent | 22d98874501afa7d5d6e9a2cf154d969a7d927a9 (diff) |
Small optimisation in function WriteFile():
only read the file if it its size equals the length of the rdata string.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@4181 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin')
-rw-r--r-- | lib/sbin/CSTUtils.pl | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/sbin/CSTUtils.pl b/lib/sbin/CSTUtils.pl index 0090852d..e6c9abde 100644 --- a/lib/sbin/CSTUtils.pl +++ b/lib/sbin/CSTUtils.pl @@ -176,9 +176,14 @@ sub WriteFile $data_in = ""; if (-e $filename) { - open(IN, "< $filename"); - $data_in = join ('', <IN>); - close IN; + # only read the file if it its size equals the length of the rdata string + my @fileinfo = stat ($filename); + if ($fileinfo[7] == length ($$rdata)) + { + open(IN, "< $filename"); + $data_in = join ('', <IN>); + close IN; + } } if ($$rdata ne $data_in) |