upload_symbols: optimize tarball cache usage a bit

Rather than constantly recreate the tarball cache object, do it at
the start of the function.

BUG=chromium:441624
TEST=`./cbuildbot/run_tests` passes

Change-Id: I9cdd4d8264bb6d1ed166a37c2b67cf9f6f594a31
Reviewed-on: https://chromium-review.googlesource.com/239433
Reviewed-by: Yu-Ju Hong <yjhong@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Yu-Ju Hong <yjhong@chromium.org>
diff --git a/scripts/upload_symbols.py b/scripts/upload_symbols.py
index 008b458..c8caf54 100644
--- a/scripts/upload_symbols.py
+++ b/scripts/upload_symbols.py
@@ -476,6 +476,10 @@
   Returns:
     Yield every viable sym file.
   """
+  cache_dir = commandline.GetCacheDir()
+  common_path = os.path.join(cache_dir, constants.COMMON_CACHE)
+  tar_cache = cache.TarballCache(common_path)
+
   for p in paths:
     # Pylint is confused about members of ParseResult.
 
@@ -486,9 +490,6 @@
       for p in ctx.LS(p):
         cros_build_lib.Info('processing files inside %s', p)
         o = urlparse.urlparse(p)
-        cache_dir = commandline.GetCacheDir()
-        common_path = os.path.join(cache_dir, constants.COMMON_CACHE)
-        tar_cache = cache.TarballCache(common_path)
         key = ('%s%s' % (o.netloc, o.path)).split('/')  # pylint: disable=E1101
         # The common cache will not be LRU, removing the need to hold a read
         # lock on the cached gsutil.