diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py
index 98be41c29..06bb7fbfb 100644
--- a/tools/donate-cpu-server.py
+++ b/tools/donate-cpu-server.py
@@ -521,15 +521,14 @@ def check_library_report(result_path, message_id):
function_name = line[(line.find(': Function ') + len(': Function ')):line.rfind('should have') - 1]
function_counts[function_name] = function_counts.setdefault(function_name, 0) + 1
- functions_shown = 0
+ function_details_list = list()
for function_name, count in sorted(function_counts.iteritems(), key=lambda (k, v): (v, k), reverse=True):
- if functions_shown >= functions_shown_max:
+ if len(function_details_list) >= functions_shown_max:
break
- html += str(count).rjust(column_widths[0]) + ' ' + \
- '' + function_name + '\n'
- functions_shown += 1
+ function_details_list.append(str(count).rjust(column_widths[0]) + ' ' +
+ '' + function_name + '\n')
- html += '\n'
+ html += ''.join(function_details_list)
html += '\n'
html += '