Skip to content

Commit cfa5e14

Browse files
committed
RC9; better pairlist creation
1 parent 731c1c2 commit cfa5e14

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ aio
365365
#> < recvAio >
366366
#> - $data for message data
367367
aio$data |> str()
368-
#> num [1:100000000] 0.521 -1.154 0.624 0.373 -0.547 ...
368+
#> num [1:100000000] -0.366 0.462 0.825 -1.21 -1.245 ...
369369
```
370370

371371
As `call_aio()` is blocking and will wait for completion, an alternative
@@ -526,11 +526,11 @@ ncurl("https://httpbin.org/headers")
526526
#> [1] 7b 0a 20 20 22 68 65 61 64 65 72 73 22 3a 20 7b 0a 20 20 20 20 22 48 6f 73
527527
#> [26] 74 22 3a 20 22 68 74 74 70 62 69 6e 2e 6f 72 67 22 2c 20 0a 20 20 20 20 22
528528
#> [51] 58 2d 41 6d 7a 6e 2d 54 72 61 63 65 2d 49 64 22 3a 20 22 52 6f 6f 74 3d 31
529-
#> [76] 2d 36 33 36 34 66 31 64 31 2d 31 39 31 35 36 30 63 38 35 61 62 39 36 62 62
530-
#> [101] 32 33 39 61 32 33 31 36 33 22 0a 20 20 7d 0a 7d 0a
529+
#> [76] 2d 36 33 36 35 31 64 39 65 2d 37 64 34 65 62 31 34 32 35 35 63 62 36 30 66
530+
#> [101] 61 36 35 35 65 61 30 39 37 22 0a 20 20 7d 0a 7d 0a
531531
#>
532532
#> $data
533-
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-6364f1d1-191560c85ab96bb239a23163\"\n }\n}\n"
533+
#> [1] "{\n \"headers\": {\n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-63651d9e-7d4eb14255cb60fa655ea097\"\n }\n}\n"
534534
```
535535

536536
For advanced use, supports additional HTTP methods such as POST or PUT.
@@ -551,13 +551,13 @@ res
551551

552552
call_aio(res)$headers
553553
#> $Date
554-
#> [1] "Fri, 04 Nov 2022 11:04:50 GMT"
554+
#> [1] "Fri, 04 Nov 2022 14:11:42 GMT"
555555
#>
556556
#> $Server
557557
#> [1] "gunicorn/19.9.0"
558558

559559
res$data
560-
#> [1] "{\n \"args\": {}, \n \"data\": \"{\\\"key\\\": \\\"value\\\"}\", \n \"files\": {}, \n \"form\": {}, \n \"headers\": {\n \"Authorization\": \"Bearer APIKEY\", \n \"Content-Length\": \"16\", \n \"Content-Type\": \"application/json\", \n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-6364f1d2-259652e3288ea25d5fb454a3\"\n }, \n \"json\": {\n \"key\": \"value\"\n }, \n \"origin\": \"213.86.169.34\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
560+
#> [1] "{\n \"args\": {}, \n \"data\": \"{\\\"key\\\": \\\"value\\\"}\", \n \"files\": {}, \n \"form\": {}, \n \"headers\": {\n \"Authorization\": \"Bearer APIKEY\", \n \"Content-Length\": \"16\", \n \"Content-Type\": \"application/json\", \n \"Host\": \"httpbin.org\", \n \"X-Amzn-Trace-Id\": \"Root=1-63651d9e-37efe928438712bb5a2245d6\"\n }, \n \"json\": {\n \"key\": \"value\"\n }, \n \"origin\": \"213.86.169.34\", \n \"url\": \"http://httpbin.org/post\"\n}\n"
561561
```
562562

563563
In this respect, it may be used as a performant and lightweight method
@@ -599,10 +599,10 @@ s |> send('{"action": "subscribe", "symbols": "EURUSD"}')
599599
#> [1] 0
600600

601601
s |> recv()
602-
#> [1] "{\"s\":\"EURUSD\",\"a\":0.9792,\"b\":0.9789,\"dc\":\"0.4371\",\"dd\":\"0.0043\",\"ppms\":false,\"t\":1667559891000}"
602+
#> [1] "{\"s\":\"EURUSD\",\"a\":0.98913,\"b\":0.98911,\"dc\":\"1.4366\",\"dd\":\"0.0142\",\"ppms\":false,\"t\":1667571103000}"
603603

604604
s |> recv()
605-
#> [1] "{\"s\":\"EURUSD\",\"a\":0.9791,\"b\":0.97908,\"dc\":\"0.4269\",\"dd\":\"0.0042\",\"ppms\":false,\"t\":1667559892000}"
605+
#> [1] "{\"s\":\"EURUSD\",\"a\":0.98913,\"b\":0.9891,\"dc\":\"1.4366\",\"dd\":\"0.0142\",\"ppms\":false,\"t\":1667571103000}"
606606

607607
close(s)
608608
```

src/init.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,16 @@ static void RegisterSymbols(void) {
7878

7979
static void PreserveObjects(void) {
8080
R_PreserveObject(nano_aioFormals = Rf_list1(Rf_install(".")));
81-
SEXP result, msgdata, msgraw, nstatus, nheaders, nraw, ndata;
82-
PROTECT(result = Rf_lang3(nano_DotcallSymbol, Rf_install("rnng_aio_result"), nano_DataSymbol));
83-
PROTECT(msgdata = Rf_lang3(nano_DotcallSymbol, Rf_install("rnng_aio_get_msgdata"), nano_ResultSymbol));
84-
PROTECT(msgraw = Rf_lang3(nano_DotcallSymbol, Rf_install("rnng_aio_get_msgraw"), nano_ResultSymbol));
85-
R_PreserveObject(nano_aioFuncs = Rf_list3(result, msgdata, msgraw));
81+
R_PreserveObject(nano_aioFuncs = Rf_allocVector(LISTSXP, 3));
82+
SETCAR(nano_aioFuncs, Rf_lang3(nano_DotcallSymbol, Rf_install("rnng_aio_result"), nano_DataSymbol));
83+
SETCADR(nano_aioFuncs, Rf_lang3(nano_DotcallSymbol, Rf_install("rnng_aio_get_msgdata"), nano_ResultSymbol));
84+
SETCADDR(nano_aioFuncs, Rf_lang3(nano_DotcallSymbol, Rf_install("rnng_aio_get_msgraw"), nano_ResultSymbol));
8685
SEXP nano_AioHttpSymbol = Rf_install("rnng_aio_http");
87-
PROTECT(nstatus = Rf_lang5(nano_DotcallSymbol, nano_AioHttpSymbol, nano_ContextSymbol, nano_ResponseSymbol, Rf_ScalarInteger(0)));
88-
PROTECT(nheaders = Rf_lang5(nano_DotcallSymbol, nano_AioHttpSymbol, nano_ContextSymbol, nano_ResponseSymbol, Rf_ScalarInteger(1)));
89-
PROTECT(nraw = Rf_lang5(nano_DotcallSymbol, nano_AioHttpSymbol, nano_ContextSymbol, nano_ResponseSymbol, Rf_ScalarInteger(2)));
90-
PROTECT(ndata = Rf_lang5(nano_DotcallSymbol, nano_AioHttpSymbol, nano_ContextSymbol, nano_ResponseSymbol, Rf_ScalarInteger(3)));
91-
R_PreserveObject(nano_aioNFuncs = Rf_list4(nstatus, nheaders, nraw, ndata));
92-
UNPROTECT(7);
86+
R_PreserveObject(nano_aioNFuncs = Rf_allocVector(LISTSXP, 4));
87+
SETCAR(nano_aioNFuncs, Rf_lang5(nano_DotcallSymbol, nano_AioHttpSymbol, nano_ContextSymbol, nano_ResponseSymbol, Rf_ScalarInteger(0)));
88+
SETCADR(nano_aioNFuncs, Rf_lang5(nano_DotcallSymbol, nano_AioHttpSymbol, nano_ContextSymbol, nano_ResponseSymbol, Rf_ScalarInteger(1)));
89+
SETCADDR(nano_aioNFuncs, Rf_lang5(nano_DotcallSymbol, nano_AioHttpSymbol, nano_ContextSymbol, nano_ResponseSymbol, Rf_ScalarInteger(2)));
90+
SETCADDDR(nano_aioNFuncs, Rf_lang5(nano_DotcallSymbol, nano_AioHttpSymbol, nano_ContextSymbol, nano_ResponseSymbol, Rf_ScalarInteger(3)));
9391
R_PreserveObject(nano_error = Rf_mkString("errorValue"));
9492
R_PreserveObject(nano_ncurlAio = Rf_allocVector(STRSXP, 2));
9593
SET_STRING_ELT(nano_ncurlAio, 0, Rf_mkChar("ncurlAio"));

0 commit comments

Comments
 (0)