]> granicus.if.org Git - graphviz/commitdiff
manage _run member of Text as a value instead of a pointer
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 13 Apr 2021 01:48:32 +0000 (18:48 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Mon, 19 Apr 2021 03:53:34 +0000 (20:53 -0700)
This member is never set to NULL and the Run class is not involved in any
inheritance hierarchy. So there is no need to heap-allocate it or pass it around
by pointer.

plugin/visio/VisioText.cpp
plugin/visio/VisioText.h

index 0912b2d40bb5129c5bf29341196acfeafc9105b1..a271fc883cbd5e88cdb67dc575e33ab5684edbbc 100644 (file)
@@ -106,27 +106,21 @@ namespace Visio
                                job->obj->pencolor.u.rgba[0],
                                job->obj->pencolor.u.rgba[1],
                                job->obj->pencolor.u.rgba[2]),
-                       new Run(
+                       Run(
                                bounds,
                                span->str));
        }
        
-       Text::Text(const Para &para, const Char &chars, Run* run):
+       Text::Text(const Para &para, const Char &chars, const Run &run):
                _para(para),
                _chars(chars),
                _run(run)
        {
        }
        
-       Text::~Text()
-       {
-               if (_run)
-                       delete _run;
-       }
-       
        boxf Text::GetBounds() const
        {
-               return _run->GetBounds();
+               return _run.GetBounds();
        }
        
        void Text::Print(GVJ_t* job) const
@@ -137,8 +131,7 @@ namespace Visio
        
        void Text::PrintRun(GVJ_t* job, unsigned int index) const
        {
-               if (_run)
-                       _run->Print(job, index);
+               _run.Print(job, index);
        }
 
        Hyperlink* Hyperlink::CreateHyperlink(GVJ_t*, char* url, char* tooltip, char* target, char*)
index ffe56864f8a10ccd907e566829161f0c3d4876c0..54c597581142db2240b64adda24e68c53f2bfb4d 100644 (file)
@@ -79,19 +79,17 @@ namespace Visio
        public:
                static Text* CreateText(GVJ_t* job, pointf p, textspan_t* span);
                
-               ~Text();
-               
                boxf GetBounds() const;
                
                void Print(GVJ_t* job) const;
                void PrintRun(GVJ_t* job, unsigned int index) const;
                
        private:
-               Text(const Para &para, const Char &chars, Run* run);
+               Text(const Para &para, const Char &chars, const Run &run);
                
                Para _para;
                Char _chars;
-               Run* _run;
+               Run _run;
        };
        
        /* Hyperlink VDX element */