From 25e2f28b024f15967940ab56a338359da2034a05 Mon Sep 17 00:00:00 2001 From: wangyix Date: Wed, 4 Jun 2014 11:30:35 -0700 Subject: [PATCH] more cleanup --- interface/src/DatagramProcessor.cpp | 3 +-- interface/src/main.cpp | 3 --- libraries/networking/src/LimitedNodeList.cpp | 11 +---------- libraries/shared/src/MovingPercentile.cpp | 14 ++++++++++++-- libraries/shared/src/MovingPercentile.h | 10 +++++++++- 5 files changed, 23 insertions(+), 18 deletions(-) diff --git a/interface/src/DatagramProcessor.cpp b/interface/src/DatagramProcessor.cpp index ccbd793e6b..56078c1a8d 100644 --- a/interface/src/DatagramProcessor.cpp +++ b/interface/src/DatagramProcessor.cpp @@ -35,7 +35,7 @@ void DatagramProcessor::processDatagrams() { Application* application = Application::getInstance(); NodeList* nodeList = NodeList::getInstance(); - + while (NodeList::getInstance()->getNodeSocket().hasPendingDatagrams()) { incomingPacket.resize(nodeList->getNodeSocket().pendingDatagramSize()); nodeList->getNodeSocket().readDatagram(incomingPacket.data(), incomingPacket.size(), @@ -45,7 +45,6 @@ void DatagramProcessor::processDatagrams() { _byteCount += incomingPacket.size(); if (nodeList->packetVersionAndHashMatch(incomingPacket)) { - // only process this packet if we have a match on the packet version switch (packetTypeForPacket(incomingPacket)) { case PacketTypeMixedAudio: diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 7e5b539eb1..2bb0633f24 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -15,9 +15,6 @@ #include #include -// DEBUG!!!!!! -#include "DatagramProcessor.h" - int main(int argc, const char * argv[]) { QElapsedTimer startupTime; startupTime.start(); diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index 3823ddc426..8c24ef25a4 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -151,10 +151,6 @@ void LimitedNodeList::changeSendSocketBufferSize(int numSendBytes) { } bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) { - -quint64 start = usecTimestampNow(); -quint64 end; - PacketType checkType = packetTypeForPacket(packet); int numPacketTypeBytes = numBytesArithmeticCodingFromBuffer(packet.data()); @@ -192,14 +188,9 @@ quint64 end; << uuidFromPacketHeader(packet); } } else { - - if ((end = usecTimestampNow()) - start > 100) { - printf("\t\t\t\t version and hash match long diff: %d\n", end - start); - } - return true; } - + return false; } diff --git a/libraries/shared/src/MovingPercentile.cpp b/libraries/shared/src/MovingPercentile.cpp index ba2b919d32..07b633e93e 100644 --- a/libraries/shared/src/MovingPercentile.cpp +++ b/libraries/shared/src/MovingPercentile.cpp @@ -1,3 +1,13 @@ +// +// MovingPercentile.cpp +// libraries/shared/src +// +// Created by Yixin Wang on 6/4/2014 +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + #include "MovingPercentile.h" MovingPercentile::MovingPercentile(int numSamples, float percentile) @@ -23,7 +33,7 @@ void MovingPercentile::updatePercentile(float sample) { _sampleAges[i]++; } - // find index in _samplesSorted to insert new sample. + // find index at which to insert new sample in _samplesSorted int newSampleIndex; if (_numExistingSamples < _numSamples) { // if samples have not been filled yet, this will be the next empty spot @@ -40,7 +50,7 @@ void MovingPercentile::updatePercentile(float sample) { while (_sampleAges[newSampleIndex] != _numExistingSamples) { newSampleIndex++; } } - // insert new sample at that index + // insert new sample _samplesSorted[newSampleIndex] = sample; _sampleAges[newSampleIndex] = 0; diff --git a/libraries/shared/src/MovingPercentile.h b/libraries/shared/src/MovingPercentile.h index d4a43363e1..94a4f36da5 100644 --- a/libraries/shared/src/MovingPercentile.h +++ b/libraries/shared/src/MovingPercentile.h @@ -1,8 +1,16 @@ +// +// MovingPercentile.h +// libraries/shared/src +// +// Created by Yixin Wang on 6/4/2014 +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// #ifndef hifi_MovingPercentile_h #define hifi_MovingPercentile_h - class MovingPercentile { public: