FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Deque by zloyuser · Pull Request #2 · phpinnacle/ext-buffer · GitHub

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cc  (1) .cpp  (1) .hpp  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
14 changes: 2 additions & 12 deletions Buffer.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@
Buffer::Buffer() noexcept {
}

Buffer::Buffer(const std::vector<unsigned char> &_buffer) noexcept:
buffer(_buffer) {
}

void Buffer::clear() noexcept {
buffer.clear();
}

void Buffer::write(char * str, long length) noexcept {
void Buffer::write(char * str, unsigned long length) noexcept {
buffer.insert(buffer.end(), str, str + length);
}

Expand All @@ -45,13 +41,7 @@ void Buffer::merge(const Buffer &other) noexcept {
}

std::string Buffer::bytes() const noexcept {
std::stringstream stream;

unsigned long long size = buffer.size();
for (unsigned long long i = 0; i < size; ++i)
stream << buffer[i];

return stream.str();
return std::string(buffer.begin(), buffer.end());
}

std::string Buffer::flush() noexcept {
Expand Down
9 changes: 4 additions & 5 deletions Buffer.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@
*/

#pragma once
#include <vector>
#include <sstream>
#include <deque>
#include <string>
#include <exception>

struct BufferOverflow : public std::exception {};

class Buffer {
public:
Buffer() noexcept;
Buffer(const std::vector<unsigned char>&) noexcept;

void clear() noexcept;
void write(char * str, long length) noexcept;
void write(char * str, unsigned long length) noexcept;
void discard(unsigned long long n);

unsigned long long size() const noexcept;
Expand Down Expand Up @@ -102,5 +101,5 @@ class Buffer {

~Buffer();
private:
std::vector<unsigned char> buffer;
std::deque<unsigned char> buffer;
};
2 changes: 1 addition & 1 deletion buffer.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ static zend_function_entry buffer_object_methods[] = {
};

static zend_object* buffer_object_create(zend_class_entry *ce) {
buffer_object *objval = (buffer_object*) ecalloc(1, sizeof(buffer_object) + zend_object_properties_size(ce));
buffer_object *objval = (buffer_object*) emalloc(sizeof(buffer_object) + zend_object_properties_size(ce));

zend_object* ret = buffer_object_to_zend_object(objval);

Expand Down

Back | FazBrowse Home | New Git URL