]> granicus.if.org Git - graphviz/commitdiff
visio plugin: manage _chars member of Text as a value instead of a pointer
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 8 Apr 2021 00:39:33 +0000 (17:39 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Apr 2021 23:07:40 +0000 (16:07 -0700)
This member is never set to NULL and the Char 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 7fc98263e3f4dc50b4bf8887a1e08b5b5f1eaa65..3417c36b6e4ab164c2c8ca0071f7dc003d84e159 100644 (file)
@@ -105,7 +105,7 @@ namespace Visio
                return new Text(
                        Para(
                                horzAlign),
-                       new Char(
+                       Char(
                                span->font->size,
                                job->obj->pencolor.u.rgba[0],
                                job->obj->pencolor.u.rgba[1],
@@ -115,7 +115,7 @@ namespace Visio
                                span->str));
        }
        
-       Text::Text(const Para &para, Char* chars, Run* run):
+       Text::Text(const Para &para, const Char &chars, Run* run):
                _para(para),
                _chars(chars),
                _run(run)
@@ -124,8 +124,6 @@ namespace Visio
        
        Text::~Text()
        {
-               if (_chars)
-                       delete _chars;
                if (_run)
                        delete _run;
        }
@@ -138,8 +136,7 @@ namespace Visio
        void Text::Print(GVJ_t* job) const
        {
                _para.Print(job);
-               if (_chars)
-                       _chars->Print(job);
+               _chars.Print(job);
        }
        
        void Text::PrintRun(GVJ_t* job, unsigned int index) const
index f4b5bb8feb6b40ade2b5f96b700d94a81c14b737..7e71ffe9dea7f0ef3930d21d7fe299ac98dd45e3 100644 (file)
@@ -87,10 +87,10 @@ namespace Visio
                void PrintRun(GVJ_t* job, unsigned int index) const;
                
        private:
-               Text(const Para &para, Char* chars, Run* run);
+               Text(const Para &para, const Char &chars, Run* run);
                
                Para _para;
-               Char* _chars;
+               Char _chars;
                Run* _run;
        };