Implement reference counting (#592)

This commit is contained in:
Daniel Wirtz
2019-06-05 23:15:39 +02:00
committed by GitHub
parent 3ed76a97f0
commit 0484a6b740
601 changed files with 261645 additions and 146131 deletions

View File

@ -1,4 +1,4 @@
export function bswap<T>(value: T): T {
export function bswap<T extends number>(value: T): T {
if (isInteger<T>()) {
if (sizeof<T>() == 2) {
return <T>((value << 8) | ((value >> 8) & <T>0x00FF));
@ -25,8 +25,7 @@ export function bswap<T>(value: T): T {
return value;
}
@inline
export function bswap16<T>(value: T): T {
export function bswap16<T extends number>(value: T): T {
if (isInteger<T>() && sizeof<T>() <= 4) {
if (sizeof<T>() == 2) {
return <T>((value << 8) | ((value >> 8) & <T>0x00FF));