Skip to content

Commit 8132806

Browse files
committed
pyembed: store ImporterState as Arc<T> instead of Arc<Box<T>>
Arc<T> is already on the heap and doesn't need an inner Box<T>.
1 parent 0da2a0f commit 8132806

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

pyembed/src/importer.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ impl Drop for ImporterState {
473473
// methods call into non-macro implemented methods named <method>_impl which
474474
// are defined below in separate `impl {}` blocks.
475475
py_class!(class OxidizedFinder |py| {
476-
data state: Arc<Box<ImporterState>>;
476+
data state: Arc<ImporterState>;
477477

478478
// Start of importlib.abc.MetaPathFinder interface.
479479

@@ -914,15 +914,15 @@ impl OxidizedFinder {
914914

915915
let importer = OxidizedFinder::create_instance(
916916
py,
917-
Arc::new(Box::new(ImporterState::new(
917+
Arc::new(ImporterState::new(
918918
py,
919919
&m,
920920
&bootstrap_module,
921921
resources_state,
922922
false,
923923
None,
924924
None,
925-
)?)),
925+
)?),
926926
)?;
927927

928928
Ok(importer)
@@ -1006,15 +1006,15 @@ fn oxidized_finder_new(
10061006

10071007
let importer = OxidizedFinder::create_instance(
10081008
py,
1009-
Arc::new(Box::new(ImporterState::new(
1009+
Arc::new(ImporterState::new(
10101010
py,
10111011
&m,
10121012
&bootstrap_module,
10131013
&resources_state,
10141014
true,
10151015
resources_data,
10161016
mapped,
1017-
)?)),
1017+
)?),
10181018
)?;
10191019

10201020
// We effectively transferred ownership of resources_state just above.
@@ -1091,7 +1091,7 @@ impl OxidizedFinder {
10911091
//
10921092
// Implements importlib.abc.ResourceReader.
10931093
py_class!(class OxidizedResourceReader |py| {
1094-
data state: Arc<Box<ImporterState>>;
1094+
data state: Arc<ImporterState>;
10951095
data package: String;
10961096

10971097
def open_resource(&self, resource: &PyString) -> PyResult<PyObject> {
@@ -1181,7 +1181,7 @@ impl OxidizedResourceReader {
11811181
//
11821182
// This implements importlib.abc.Traversable.
11831183
py_class!(class PyOxidizerTraversable |py| {
1184-
data state: Arc<Box<ImporterState>>;
1184+
data state: Arc<ImporterState>;
11851185
data path: String;
11861186

11871187
// Yield Traversable objects in self.

pyembed/src/package_metadata.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use {
1818

1919
// A importlib.metadata.Distribution allowing access to package distribution data.
2020
py_class!(class OxidizedDistribution |py| {
21-
data state: Arc<Box<ImporterState>>;
21+
data state: Arc<ImporterState>;
2222
data package: String;
2323

2424
def read_text(&self, filename: &PyString) -> PyResult<PyObject> {
@@ -48,7 +48,7 @@ py_class!(class OxidizedDistribution |py| {
4848

4949
impl OxidizedDistribution {
5050
fn read_text_impl(&self, py: Python, filename: &PyString) -> PyResult<PyObject> {
51-
let state: &Arc<Box<ImporterState>> = self.state(py);
51+
let state: &Arc<ImporterState> = self.state(py);
5252
let package: &str = self.package(py);
5353
let resources_state = state.get_resources_state();
5454

@@ -86,7 +86,7 @@ impl OxidizedDistribution {
8686
/// The returned object will have keys that name the various bits of
8787
/// metadata.
8888
fn metadata_impl(&self, py: Python) -> PyResult<PyObject> {
89-
let state: &Arc<Box<ImporterState>> = self.state(py);
89+
let state: &Arc<ImporterState> = self.state(py);
9090
let package: &str = self.package(py);
9191
let resources_state = state.get_resources_state();
9292

@@ -178,7 +178,7 @@ impl OxidizedDistribution {
178178
/// Find package metadata distributions given search criteria.
179179
pub(crate) fn find_distributions(
180180
py: Python,
181-
state: Arc<Box<ImporterState>>,
181+
state: Arc<ImporterState>,
182182
name: Option<PyObject>,
183183
_path: Option<PyObject>,
184184
) -> PyResult<PyObject> {

0 commit comments

Comments
 (0)