Unverified Commit 0783eb80 authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

perf: Remove needless `Arc` (#75601)

### What?

Remove one allocation per `transform()` and `minify()`.

### Why?

We don't need to allocate `Compiler` in an `Arc`, because we don't share it.
parent 576e04c1
...@@ -98,10 +98,10 @@ fn init() { ...@@ -98,10 +98,10 @@ fn init() {
} }
#[inline] #[inline]
fn get_compiler() -> Arc<Compiler> { fn get_compiler() -> Compiler {
let cm = Arc::new(SourceMap::new(FilePathMapping::empty())); let cm = Arc::new(SourceMap::new(FilePathMapping::empty()));
Arc::new(Compiler::new(cm)) Compiler::new(cm)
} }
pub fn complete_output( pub fn complete_output(
...@@ -136,8 +136,6 @@ pub fn complete_output( ...@@ -136,8 +136,6 @@ pub fn complete_output(
Ok(js_output) Ok(js_output)
} }
pub type ArcCompiler = Arc<Compiler>;
static REGISTER_ONCE: Once = Once::new(); static REGISTER_ONCE: Once = Once::new();
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
......
...@@ -25,7 +25,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR ...@@ -25,7 +25,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
use std::sync::Arc;
use napi::bindgen_prelude::*; use napi::bindgen_prelude::*;
use rustc_hash::FxHashMap; use rustc_hash::FxHashMap;
...@@ -42,7 +41,7 @@ use swc_core::{ ...@@ -42,7 +41,7 @@ use swc_core::{
use crate::{get_compiler, util::MapErr}; use crate::{get_compiler, util::MapErr};
pub struct MinifyTask { pub struct MinifyTask {
c: Arc<swc_core::base::Compiler>, c: swc_core::base::Compiler,
code: MinifyTarget, code: MinifyTarget,
opts: swc_core::base::config::JsMinifyOptions, opts: swc_core::base::config::JsMinifyOptions,
} }
......
...@@ -31,7 +31,6 @@ use std::{ ...@@ -31,7 +31,6 @@ use std::{
fs::read_to_string, fs::read_to_string,
panic::{catch_unwind, AssertUnwindSafe}, panic::{catch_unwind, AssertUnwindSafe},
rc::Rc, rc::Rc,
sync::Arc,
}; };
use anyhow::{anyhow, bail, Context as _}; use anyhow::{anyhow, bail, Context as _};
...@@ -58,7 +57,7 @@ pub enum Input { ...@@ -58,7 +57,7 @@ pub enum Input {
} }
pub struct TransformTask { pub struct TransformTask {
pub c: Arc<Compiler>, pub c: Compiler,
pub input: Input, pub input: Input,
pub options: Buffer, pub options: Buffer,
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment