Blame 0028-inst_simple-inst_dir-make-fast-case-faster.patch

Harald Hoyer 55891e
From 3f590c7840bb0897154f66a277be6bfaa63677bd Mon Sep 17 00:00:00 2001
Harald Hoyer 55891e
From: John Reiser <jreiser@BitWagon.com>
Harald Hoyer 55891e
Date: Fri, 26 Aug 2011 13:01:33 -0700
Harald Hoyer 55891e
Subject: [PATCH] inst_simple, inst_dir: make fast case faster
Harald Hoyer 55891e
Harald Hoyer 55891e
This small stuff saves 1.7% per dropped statement during "dracut --profile".
Harald Hoyer 55891e
Fixing the comment about /lib -> lib64 is REQUIRED!
Harald Hoyer 55891e
---
Harald Hoyer 55891e
 dracut-functions |   16 +++++-----------
Harald Hoyer 55891e
 1 files changed, 5 insertions(+), 11 deletions(-)
Harald Hoyer 55891e
Harald Hoyer 55891e
diff --git a/dracut-functions b/dracut-functions
Harald Hoyer 55891e
index 3edd4c7..f41fc7d 100755
Harald Hoyer 55891e
--- a/dracut-functions
Harald Hoyer 55891e
+++ b/dracut-functions
Harald Hoyer 55891e
@@ -266,19 +266,13 @@ check_vol_slaves() {
Harald Hoyer 55891e
 }
Harald Hoyer 55891e
 
Harald Hoyer 55891e
 # Install a directory, keeping symlinks as on the original system.
Harald Hoyer 55891e
-# Example: if /lib64 points to /lib on the host, "inst_dir /lib/file"
Harald Hoyer 55891e
+# Example: if /lib points to /lib64 on the host, "inst_dir /lib/file"
Harald Hoyer 55891e
 # will create ${initdir}/lib64, ${initdir}/lib64/file,
Harald Hoyer 55891e
 # and a symlink ${initdir}/lib -> lib64.
Harald Hoyer 55891e
 inst_dir() {
Harald Hoyer 55891e
-    local _file=""
Harald Hoyer 55891e
-    local _oldifs="$IFS"
Harald Hoyer 55891e
-    local _part
Harald Hoyer 55891e
-    local _dir="$1"
Harald Hoyer 55891e
+    [[ -e ${initdir}"$1" ]] && return 0  # already there
Harald Hoyer 55891e
 
Harald Hoyer 55891e
-    # fast out
Harald Hoyer 55891e
-    [[ -e ${initdir}$_dir ]] && return 0
Harald Hoyer 55891e
-
Harald Hoyer 55891e
-    _part=${_dir%/*}
Harald Hoyer 55891e
+    local _dir="$1" _part=${_dir%/*} _file
Harald Hoyer 55891e
     while [[ "$_part" != "${_part%/*}" ]] && ! [[ -e "${initdir}${_part}" ]]; do
Harald Hoyer 55891e
         _dir="$_part $_dir"
Harald Hoyer 55891e
         _part=${_part%/*}
Harald Hoyer 55891e
@@ -310,9 +304,9 @@ inst_dir() {
Harald Hoyer 55891e
 # Location of the image dir is assumed to be $initdir
Harald Hoyer 55891e
 # We never overwrite the target if it exists.
Harald Hoyer 55891e
 inst_simple() {
Harald Hoyer 55891e
-    local _src target
Harald Hoyer 55891e
     [[ -f $1 ]] || return 1
Harald Hoyer 55891e
-    _src=$1 target="${2:-$1}"
Harald Hoyer 55891e
+
Harald Hoyer 55891e
+    local _src=$1 target="${2:-$1}"
Harald Hoyer 55891e
     if ! [[ -d ${initdir}$target ]]; then
Harald Hoyer 55891e
         [[ -e ${initdir}$target ]] && return 0
Harald Hoyer 55891e
         [[ -h ${initdir}$target ]] && return 0