-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
js: times.now generates 1193 LOC (4.5K in debug mode) #503
Comments
After changing to 1272 => 1293 After minifying, it reduces 1kb or less 24kb => 23kb Edited: |
what do you mean by that? some details would clarify also, make sure you measure for contiguous case branches like this: case 26:
case 27:
case 28:
case 29:
case 30:
case 31: should be replaced by range checks, eg: |
I doubt I just change the case statement to if ((Temporary1 == 7)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\a"));;
}
else {
if ((Temporary1 == 8)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\b"));;
}
else {
if ((Temporary1 == 9)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\t"));;
}
else {
if ((Temporary1 == 10)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\n"));;
}
else {
if ((Temporary1 == 11)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\v"));;
}
else {
if ((Temporary1 == 12)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\f"));;
}
else {
if ((Temporary1 == 13)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\r"));;
}
else {
if ((Temporary1 == 27)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\e"));;
}
else {
if ((Temporary1 == 92)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\\\"));;
}
else {
if ((Temporary1 == 39)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\\'"));;
}
else {
if ((Temporary1 == 34)) {
s_33557848[s_33557848_Idx].push.apply(s_33557848[s_33557848_Idx], makeNimstrLit("\\\""));;
}
else {
if (((Temporary1 >= 32) & (Temporary1 <= 33)) | ((Temporary1 >= 35) & (Temporary1 <= 38)) | ((Temporary1 >= 40) & (Temporary1 <= 91)) | ((Temporary1 >= 93) & (Temporary1 <= 126))) {
addChar(s_33557848[s_33557848_Idx], c_33557849);;
} Before switch (c_33557845) {
case 7:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\a"));;
break;
case 8:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\b"));;
break;
case 9:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\t"));;
break;
case 10:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\n"));;
break;
case 11:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\v"));;
break;
case 12:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\f"));;
break;
case 13:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\r"));;
break;
case 27:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\e"));;
break;
case 92:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\\\"));;
break;
case 39:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\\'"));;
break;
case 34:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\\""));;
break;
case 32:
case 33:
case 35:
case 36:
case 37:
case 38:
case 40:
case 41:
case 42:
case 43:
case 44:
case 45:
case 46:
case 47:
case 48:
case 49:
case 50:
case 51:
case 52:
case 53:
case 54:
case 55:
case 56:
case 57:
case 58:
case 59:
case 60:
case 61:
case 62:
case 63:
case 64:
case 65:
case 66:
case 67:
case 68:
case 69:
case 70:
case 71:
case 72:
case 73:
case 74:
case 75:
case 76:
case 77:
case 78:
case 79:
case 80:
case 81:
case 82:
case 83:
case 84:
case 85:
case 86:
case 87:
case 88:
case 89:
case 90:
case 91:
case 93:
case 94:
case 95:
case 96:
case 97:
case 98:
case 99:
case 100:
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
case 107:
case 108:
case 109:
case 110:
case 111:
case 112:
case 113:
case 114:
case 115:
case 116:
case 117:
case 118:
case 119:
case 120:
case 121:
case 122:
case 123:
case 124:
case 125:
case 126:
addChar(s_33557844[s_33557844_Idx], c_33557845);;
break;
default:
s_33557844[s_33557844_Idx].push.apply(s_33557844[s_33557844_Idx], makeNimstrLit("\\x"));;
var n_33557855 = c_33557845;
addChar(s_33557844[s_33557844_Idx], makeNimstrLit("0123456789ABCDEF")[((n_33557855 & 240) >> 4)]);;
addChar(s_33557844[s_33557844_Idx], makeNimstrLit("0123456789ABCDEF")[(n_33557855 & 15)]);;
break; I may optimize it later. |
js: times.now generates 1193 LOC in -d:danger (4.5K LOC in debug mdoe)
Example
Current Output
nim r -b:js $options main
wc -l main.js
Expected Output
small codegen
Additional Information
1.5.1 devel b42e7c0
related issues (js code bloat)
case a of range
nim-lang/Nim#8821-d:danger: 549 LOC
The text was updated successfully, but these errors were encountered: