Hello,

here's a patch that speeds up aa-decode - in my case from 1.9s to 0.3s
(test log with about 900 lines, with 16 encoded lines) 

The trick is to use bash regex matching instead of calling egrep for
each line.

It would probably also be possible to replace the sed calls with bash
regex matching, but the savings would be minimal because typically 
most lines are not encoded.

BTW: Not having quotes arond the regex is intentional - with quotes
added, bash wouldn't take it as regex.


=== modified file 'utils/aa-decode'
--- utils/aa-decode     2012-10-15 22:19:49 +0000
+++ utils/aa-decode     2012-11-01 17:57:33 +0000
@@ -70,7 +70,7 @@
 while read line ; do
 
     # check if line contains encoded name= or profile=
-    if echo "$line" | egrep ' (name|profile)=[0-9a-fA-F]' >/dev/null ; then
+    if [[ "$line" =~ \ (name|profile)=[0-9a-fA-F] ]]; then
 
         # cut the encoded filename/profile name out of the line and decode it
         ne=`echo "$line" | sed 's/.* name=\([^ ]*\).*$/\\1/g'`




Regards,

Christian Boltz
-- 
I wonder how we ended up with baseurl and extra_url, now we are missing
one with a "-" like "data-dir" to violate consistency and the principle
of least surprise in all possible ways. 
[Duncan Mac-Vicar Prett in bnc#449842]


-- 
AppArmor mailing list
AppArmor@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to