X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Flazy.qh;h=ad30115a2e74c3fb00e25564cfe0e998816d42a9;hb=c6ebaefab2aca7df4648dac3ccdd4b52de45d0ed;hp=f632b38c32be69e446ba3a34e1183352bb27430b;hpb=c89dfaa4d0342b98c320621557973a65114fbdf4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/lazy.qh b/qcsrc/lib/lazy.qh index f632b38c3..ad30115a2 100644 --- a/qcsrc/lib/lazy.qh +++ b/qcsrc/lib/lazy.qh @@ -1,18 +1,20 @@ -#ifndef LAZY_H -#define LAZY_H +#pragma once #include "oo.qh" CLASS(Lazy, Object) - ATTRIB(Lazy, m_get, entity(), func_null); - CONSTRUCTOR(Lazy, entity() _compute) { this.m_get = _compute; } + ATTRIB(Lazy, m_get, entity(), func_null); + CONSTRUCTOR(Lazy, entity() _compute) + { + this.m_get = _compute; + } ENDCLASS(Lazy) #define LAZY(id) __lazy_##id -#define LAZY_NEW(id, compute) entity LAZY(id)() { \ - static bool done; \ - static entity it; \ - if (!done) { it = compute; done = true; } \ - return it; \ -} -#endif +#define LAZY_NEW(id, compute) \ + entity LAZY(id)() { \ + static bool done; \ + static entity it; \ + if (!done) { it = compute; done = true; } \ + return it; \ + }