Don't go through uBit object if not needed

This commit is contained in:
Michal Moskal
2016-04-19 11:52:44 -07:00
parent 13bdcf762d
commit c54cd21efa
5 changed files with 12 additions and 10 deletions

View File

@ -1,6 +1,7 @@
#include "ksbit.h"
#include <limits.h>
namespace String_ {
//%
StringData *charAt(StringData *s, int pos) {
@ -127,13 +128,13 @@ namespace Math_ {
//%
int random(int max) {
if (max == INT_MIN)
return -uBit.random(INT_MAX);
return -microbit_random(INT_MAX);
else if (max < 0)
return -uBit.random(-max);
return -microbit_random(-max);
else if (max == 0)
return 0;
else
return uBit.random(max);
return microbit_random(max);
}
//%
@ -298,6 +299,6 @@ namespace pxtrt {
//%
void panic(int code)
{
uBit.panic(code);
microbit_panic(code);
}
}