Change in osmo-trx[master]: lms: flush_recv: alloc buf on stack instead of heap

2019-04-26 Thread Pau Espin Pedrol
Pau Espin Pedrol has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13782 )

Change subject: lms: flush_recv: alloc buf on stack instead of heap
..

lms: flush_recv: alloc buf on stack instead of heap

No need to use the heap here since buffer is only used as a temporary
trash. Using the stack is quicker.

Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
---
M Transceiver52M/device/lms/LMSDevice.cpp
1 file changed, 1 insertion(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/Transceiver52M/device/lms/LMSDevice.cpp 
b/Transceiver52M/device/lms/LMSDevice.cpp
index 05904e8..064d742 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -450,7 +450,7 @@
 {
#define CHUNK 625
int len = CHUNK * tx_sps;
-   short *buffer = new short[len * 2];
+   short *buffer = (short*) alloca(sizeof(short) * len * 2);
int rc;
lms_stream_meta_t rx_metadata = {};
rx_metadata.flushPartialPacket = false;
@@ -463,7 +463,6 @@
LOGC(DDEV, DEBUG) << "Flush: Recv buffer of len " << rc << " at 
" << std::hex << rx_metadata.timestamp;
if (rc != len) {
LOGC(DDEV, ALERT) << "LMS: Device receive timed out";
-   delete[] buffer;
return false;
}

@@ -471,7 +470,6 @@
}

LOGC(DDEV, INFO) << "Initial timestamp " << ts_initial << std::endl;
-   delete[] buffer;
return true;
 }


--
To view, visit https://gerrit.osmocom.org/13782
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
Gerrit-Change-Number: 13782
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-Reviewer: Pau Espin Pedrol 
Gerrit-CC: Max 


Change in osmo-trx[master]: lms: flush_recv: alloc buf on stack instead of heap

2019-04-26 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/13782 )

Change subject: lms: flush_recv: alloc buf on stack instead of heap
..


Patch Set 1: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/13782
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
Gerrit-Change-Number: 13782
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Max 
Gerrit-Comment-Date: Fri, 26 Apr 2019 16:09:47 +
Gerrit-HasComments: No
Gerrit-HasLabels: Yes


Change in osmo-trx[master]: lms: flush_recv: alloc buf on stack instead of heap

2019-04-26 Thread Max
Max has posted comments on this change. ( https://gerrit.osmocom.org/13782 )

Change subject: lms: flush_recv: alloc buf on stack instead of heap
..


Patch Set 1:

> Using the stack is quicker.

What makes you think that? Do you have benchmark? I wouldn't be surprised if 
modern compiler optimize such a trivial case.


--
To view, visit https://gerrit.osmocom.org/13782
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
Gerrit-Change-Number: 13782
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol 
Gerrit-Reviewer: Jenkins Builder (102)
Gerrit-CC: Max 
Gerrit-Comment-Date: Fri, 26 Apr 2019 10:49:50 +
Gerrit-HasComments: No
Gerrit-HasLabels: No


Change in osmo-trx[master]: lms: flush_recv: alloc buf on stack instead of heap

2019-04-25 Thread Pau Espin Pedrol
Pau Espin Pedrol has uploaded this change for review. ( 
https://gerrit.osmocom.org/13782


Change subject: lms: flush_recv: alloc buf on stack instead of heap
..

lms: flush_recv: alloc buf on stack instead of heap

No need to use the heap here since buffer is only used as a temporary
trash. Using the stack is quicker.

Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
---
M Transceiver52M/device/lms/LMSDevice.cpp
1 file changed, 1 insertion(+), 3 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/82/13782/1

diff --git a/Transceiver52M/device/lms/LMSDevice.cpp 
b/Transceiver52M/device/lms/LMSDevice.cpp
index 05904e8..064d742 100644
--- a/Transceiver52M/device/lms/LMSDevice.cpp
+++ b/Transceiver52M/device/lms/LMSDevice.cpp
@@ -450,7 +450,7 @@
 {
#define CHUNK 625
int len = CHUNK * tx_sps;
-   short *buffer = new short[len * 2];
+   short *buffer = (short*) alloca(sizeof(short) * len * 2);
int rc;
lms_stream_meta_t rx_metadata = {};
rx_metadata.flushPartialPacket = false;
@@ -463,7 +463,6 @@
LOGC(DDEV, DEBUG) << "Flush: Recv buffer of len " << rc << " at 
" << std::hex << rx_metadata.timestamp;
if (rc != len) {
LOGC(DDEV, ALERT) << "LMS: Device receive timed out";
-   delete[] buffer;
return false;
}

@@ -471,7 +470,6 @@
}

LOGC(DDEV, INFO) << "Initial timestamp " << ts_initial << std::endl;
-   delete[] buffer;
return true;
 }


--
To view, visit https://gerrit.osmocom.org/13782
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iede8dc0903ee3865a52c8e2fd811bcde444fee33
Gerrit-Change-Number: 13782
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol