mescc: Refactor function-offset.
* module/mes/elf-util.mes (function-offset): Recurse down. Factor 5 speedup on mini-mes.c.
This commit is contained in:
parent
4b349fabf1
commit
2397e0c8e2
|
@ -72,11 +72,15 @@
|
||||||
(let ((cache '()))
|
(let ((cache '()))
|
||||||
(lambda (name functions)
|
(lambda (name functions)
|
||||||
(or (assoc-ref cache name)
|
(or (assoc-ref cache name)
|
||||||
(let* ((prefix (function-prefix name functions))
|
(let* ((functions (if (and (pair? functions) (equal? (caar functions) "exit")) functions (reverse functions)))
|
||||||
(offset (if prefix (length (functions->text (cdr prefix) '() 0 0 0))
|
(prefix (and=> (function-prefix name functions) cdr))
|
||||||
0)))
|
(offset (and prefix
|
||||||
(if (and prefix (or (equal? name "exit") (> offset 0))) (set! cache (assoc-set! cache name offset)))
|
(if (null? prefix) 0
|
||||||
offset)))))
|
(+ (length (functions->text (list (car prefix)) '() 0 0 0))
|
||||||
|
(if (null? (cdr prefix)) 0
|
||||||
|
(function-offset (caar prefix) functions)))))))
|
||||||
|
(if (and offset (or (equal? name "exit") (> offset 0))) (set! cache (assoc-set! cache name offset)))
|
||||||
|
(or offset 0))))))
|
||||||
|
|
||||||
(define label-offset
|
(define label-offset
|
||||||
(let ((cache '()))
|
(let ((cache '()))
|
||||||
|
|
Loading…
Reference in a new issue