From 63fbfb68c522865012c589e2604c4d68b4f10e5f Mon Sep 17 00:00:00 2001 From: Martin Guy Date: Tue, 7 May 2013 17:57:07 +0200 Subject: [PATCH] Make table of available RAM regions static Instead of constructing them on the stack at runtime in every call to platform_get_{first,last}_free_ram(). When there was is only one RAM region this makes no difference, as the whole thing is optimised out. However, when there are more than one region, this improves both size and speed, especially in the simple allocator, which calls these functions twice each at every call to malloc(). --- src/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common.c b/src/common.c index 61e1c4a7..d727b291 100644 --- a/src/common.c +++ b/src/common.c @@ -350,7 +350,7 @@ extern char end[]; void* platform_get_first_free_ram( unsigned id ) { - void* mstart[] = MEM_START_ADDRESS; + static void* mstart[] = MEM_START_ADDRESS; u32 p; if( id >= sizeof( mstart ) / sizeof( void* ) ) @@ -363,7 +363,7 @@ void* platform_get_first_free_ram( unsigned id ) void* platform_get_last_free_ram( unsigned id ) { - void* mend[] = MEM_END_ADDRESS; + static void* mend[] = MEM_END_ADDRESS; u32 p; if( id >= sizeof( mend ) / sizeof( void* ) )