project.py: fix performance issue with --reference when the mirrored repository has many refs

Change-Id: Id0183903597f872eee80ca32a8050125b187a3d4
diff --git a/project.py b/project.py
index 0d60fc6..ae771c4 100644
--- a/project.py
+++ b/project.py
@@ -1963,15 +1963,17 @@
           ids.add(ref_id)
           tmp.add(r)
 
-        tmp_packed = ''
-        old_packed = ''
+        tmp_packed_lines = []
+        old_packed_lines = []
 
         for r in sorted(all_refs):
           line = '%s %s\n' % (all_refs[r], r)
-          tmp_packed += line
+          tmp_packed_lines.append(line)
           if r not in tmp:
-            old_packed += line
+            old_packed_lines.append(line)
 
+        tmp_packed = ''.join(tmp_packed_lines)
+        old_packed = ''.join(old_packed_lines)
         _lwrite(packed_refs, tmp_packed)
       else:
         alt_dir = None