ali-alzyod pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=39c305cf866ca65658f270a11d7fc76cabcc613f

commit 39c305cf866ca65658f270a11d7fc76cabcc613f
Author: Ali Alzyod <ali198...@gmail.com>
Date:   Fri Jan 29 11:53:15 2021 +0200

    efl_ui_textpath: mathmatical calculations
    
    Summary: Reduce number of sqrt calls.
    
    Reviewers: cedric, raster, bu5hm4n, vtorri, woohyun, Hermet
    
    Subscribers: vtorri, bu5hm4n, raster, cedric, #reviewers, #committers
    
    Tags: #efl
    
    Maniphest Tasks: T8747
    
    Differential Revision: https://phab.enlightenment.org/D11949
---
 src/lib/elementary/efl_ui_textpath.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/lib/elementary/efl_ui_textpath.c 
b/src/lib/elementary/efl_ui_textpath.c
index 321cd20568..6638de5456 100644
--- a/src/lib/elementary/efl_ui_textpath.c
+++ b/src/lib/elementary/efl_ui_textpath.c
@@ -264,7 +264,7 @@ static void
 _text_on_line_draw(Efl_Ui_Textpath_Data *pd, int w1, int w2, int cmp, Evas_Map 
*map, Efl_Ui_Textpath_Line line)
 {
    double x1, x2, y1, y2;
-   double line_len, len, sina, cosa;
+   double line_len_2, line_len, len, sina, cosa;
    Eina_Rect r;
 
    x1 = line.start.x;
@@ -272,15 +272,17 @@ _text_on_line_draw(Efl_Ui_Textpath_Data *pd, int w1, int 
w2, int cmp, Evas_Map *
    x2 = line.end.x;
    y2 = line.end.y;
 
-   line_len = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
+   line_len_2 = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1);
    len = w2 - w1;
-   if (line_len > len)
+   if (line_len_2 > (len * len))
      {
+        line_len = sqrt(line_len_2);
         x2 = x1 + len * (x2 - x1) / line_len;
         y2 = y1 + len * (y2 - y1) / line_len;
+        line_len_2 = (x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1);
      }
 
-   len = sqrt((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1));
+   len = sqrt(line_len_2);
    sina = (y2 - y1) / len;
    cosa = (x2 - x1) / len;
 

-- 


Reply via email to