Skip to content

Commit 7759840

Browse files
committed
Remove unecessary wrapper allocation
1 parent 5b0ff8a commit 7759840

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

package/cpp/api/JsiSkPath.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ class JsiSkPath : public JsiSkWrappingSharedPtrHostObject<SkPath> {
313313
JSI_HOST_FUNCTION(makeAsWinding) {
314314
SkPath out;
315315
if (AsWinding(*getObject(), &out)) {
316-
return jsi::Object::createFromHostObject(
317-
runtime, std::make_shared<JsiSkPath>(getContext(), std::move(out)));
316+
getObject()->swap(out);
317+
return thisValue.getObject(runtime);
318318
}
319319
return jsi::Value::null();
320320
}

package/src/skia/web/api/JsiSkPath.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
6767

6868
makeAsWinding() {
6969
const result = this.ref.makeAsWinding();
70-
return result === null ? result : new JsiSkPath(this.CanvasKit, result);
70+
return result === null ? result : this;
7171
}
7272

7373
offset(dx: number, dy: number) {
@@ -141,7 +141,7 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
141141
cap: optEnum(opts.cap),
142142
}
143143
);
144-
return result === null ? result : new JsiSkPath(this.CanvasKit, result);
144+
return result === null ? result : this;
145145
}
146146

147147
close() {
@@ -292,7 +292,7 @@ export class JsiSkPath extends HostObject<Path, "Path"> implements SkPath {
292292

293293
trim(startT: number, stopT: number, isComplement: boolean) {
294294
const result = this.ref.trim(startT, stopT, isComplement);
295-
return result === null ? result : new JsiSkPath(this.CanvasKit, result);
295+
return result === null ? result : this;
296296
}
297297

298298
transform(m3: SkMatrix) {

0 commit comments

Comments
 (0)