There were a few places that were constructing a TextEncoding from a string where we can use the global singleton.
Created attachment 237384 [details] [PATCH] Proposed Fix
Comment on attachment 237384 [details] [PATCH] Proposed Fix This makes me nervous about thread safety. XMLHttpRequest can live in a worker thread, and UTF8Encoding() function is not thread safe. I'm not sure how thread safe TextEncoding itself is.
I think that all or almost all of TextEncoding and actual codec are thread safe, so it's probably just the UTF8Encoding() function that's a concern.
Comment on attachment 237384 [details] [PATCH] Proposed Fix Alexey mentioned there might be threading concerns here. The XMLHttpRequest and WorkerScriptLoader seem like they could be used from a non-main thread. This requires more thought. Putting cq- and clearing review flag for now.