Closed philippeitis closed 1 year ago
Thanks a million for these fixes! Especially the thread::sleep
one is a huge oversight that could make these crates unusable in a server context, a lingering time-bomb if you will.
Too bad I forgot about this PR when publishing previously, so maybe in future it's preferred to keep small fixes with unrelated PRs as my memory can't be trusted 😅.
I'm not sure whether these changes should be included in the previous PR - but given that it's non-essential, I've decided to keep them separate.
The first change is refactoring
remove_json_null_values
to run in linear time (thearr.remove()
call takesO(n)
time and may be calledn
times, which could accidentally lead to quadratic run times) - this incidentally makes the code a lot cleaner.The second change is using
tokio::time::sleep
in place ofstd::thread::sleep
in the upload functions (for bothgoogle-apis-common
andapi.rs
).std::thread::sleep
is blocking per https://doc.rust-lang.org/stable/std/thread/fn.sleep.html, and should not be used in async functions.