yiguolei commented on code in PR #19116:
URL: https://github.com/apache/doris/pull/19116#discussion_r1177751885


##########
be/src/geo/wkb_parse.cpp:
##########
@@ -204,10 +204,10 @@ GeoPolygon* WkbParse::readPolygon(WkbParseContext* ctx) {
         coordss.add(coords);
     }
 
-    GeoPolygon* polygon = new GeoPolygon();
+    std::unique_ptr<GeoPolygon> polygon = GeoPolygon::create_unique();
 
     if (polygon->from_coords(coordss) == GEO_PARSE_OK) {
-        return polygon;
+        return polygon.release();

Review Comment:
   and here, return std::unique_ptr<GeoPolygon>?



##########
be/src/geo/wkb_parse.cpp:
##########
@@ -150,30 +150,30 @@ GeoShape* WkbParse::readGeometry(WkbParseContext* ctx) {
 
     uint32_t geometryType = (typeInt & 0xffff) % 1000;
 
-    GeoShape* shape;
+    std::unique_ptr<GeoShape> shape;
 
     switch (geometryType) {
     case wkbType::wkbPoint:
-        shape = readPoint(ctx);
+        shape.reset(readPoint(ctx));
         break;
     case wkbType::wkbLine:
-        shape = readLine(ctx);
+        shape.reset(readLine(ctx));
         break;
     case wkbType::wkbPolygon:
-        shape = readPolygon(ctx);
+        shape.reset(readPolygon(ctx));
         break;
     default:
         return nullptr;
     }
-    return shape;
+    return shape.release();
 }
 
 GeoPoint* WkbParse::readPoint(WkbParseContext* ctx) {
     GeoCoordinateList coords = WkbParse::readCoordinateList(1, ctx);
-    GeoPoint* point = new GeoPoint();
+    std::unique_ptr<GeoPoint> point = GeoPoint::create_unique();
 
     if (point->from_coord(coords.list[0]) == GEO_PARSE_OK) {
-        return point;
+        return point.release();

Review Comment:
   return std::unique_ptr<GeoPoint>?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to