From 5891799085e1349c2e4caf95608d3bc3b4b9d05a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 8 Mar 2006 19:03:44 +0000 Subject: [PATCH] * this should improve the performance of operator= git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16658 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Region.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/kits/interface/Region.cpp b/src/kits/interface/Region.cpp index 303916b74d..ae62091ddd 100644 --- a/src/kits/interface/Region.cpp +++ b/src/kits/interface/Region.cpp @@ -413,17 +413,19 @@ BRegion & BRegion::operator=(const BRegion ®ion) { if (®ion != this) { - free(data); bound = region.bound; count = region.count; - data_size = region.data_size; - + + // handle reallocation if we're too small to contain + // the other region + set_size(region.data_size); + + // TODO: what is this supposed to do?? if (data_size <= 0) data_size = 1; - data = (clipping_rect *)malloc(data_size * sizeof(clipping_rect)); - - memcpy(data, region.data, count * sizeof(clipping_rect)); + if (data) + memcpy(data, region.data, count * sizeof(clipping_rect)); } return *this;