Skip to content

Commit

Permalink
8294293: Remove unused _width and _newlines field in outputStream
Browse files Browse the repository at this point in the history
Reviewed-by: rehn, dholmes
  • Loading branch information
jdksjolen authored and coleenp committed Sep 30, 2022
1 parent c2ce43c commit 052a924
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
25 changes: 11 additions & 14 deletions src/hotspot/share/utilities/ostream.cpp
Expand Up @@ -43,32 +43,29 @@
extern "C" void jio_print(const char* s, size_t len);
extern "C" int jio_printf(const char *fmt, ...);

outputStream::outputStream(int width) {
_width = width;
outputStream::outputStream() {
_position = 0;
_newlines = 0;
_precount = 0;
_indentation = 0;
_scratch = NULL;
_scratch_len = 0;
}

outputStream::outputStream(int width, bool has_time_stamps) {
_width = width;
outputStream::outputStream(bool has_time_stamps) {
_position = 0;
_newlines = 0;
_precount = 0;
_indentation = 0;
_scratch = NULL;
_scratch_len = 0;
if (has_time_stamps) _stamp.update();
}

void outputStream::update_position(const char* s, size_t len) {
bool outputStream::update_position(const char* s, size_t len) {
bool saw_newline = false;
for (size_t i = 0; i < len; i++) {
char ch = s[i];
if (ch == '\n') {
_newlines += 1;
saw_newline = true;
_precount += _position + 1;
_position = 0;
} else if (ch == '\t') {
Expand All @@ -79,6 +76,7 @@ void outputStream::update_position(const char* s, size_t len) {
_position += 1;
}
}
return saw_newline;
}

// Execute a vsprintf, using the given buffer if necessary.
Expand Down Expand Up @@ -400,7 +398,6 @@ void stringStream::zero_terminate() {
void stringStream::reset() {
assert(_is_frozen == false, "Modification forbidden");
_written = 0; _precount = 0; _position = 0;
_newlines = 0;
zero_terminate();
}

Expand Down Expand Up @@ -893,17 +890,17 @@ void defaultStream::write(const char* s, size_t len) {
intx holder = hold(thread_id);

if (DisplayVMOutput &&
(_outer_xmlStream == NULL || !_outer_xmlStream->inside_attrs())) {
(_outer_xmlStream == nullptr || !_outer_xmlStream->inside_attrs())) {
// print to output stream. It can be redirected by a vfprintf hook
jio_print(s, len);
}

// print to log file
if (has_log_file()) {
int nl0 = _newlines;
xmlTextStream::write(s, len);
if (has_log_file() && _outer_xmlStream != nullptr) {
_outer_xmlStream->write_text(s, len);
bool nl = update_position(s, len);
// flush the log file too, if there were any newlines
if (nl0 != _newlines){
if (nl) {
flush();
}
} else {
Expand Down
14 changes: 6 additions & 8 deletions src/hotspot/share/utilities/ostream.hpp
Expand Up @@ -48,15 +48,14 @@ class outputStream : public ResourceObj {

protected:
int _indentation; // current indentation
int _width; // width of the page
int _position; // position on the current line
int _newlines; // number of '\n' output so far
julong _precount; // number of chars output, less _position
int _position; // visual position on the current line
uint64_t _precount; // number of chars output, less than _position
TimeStamp _stamp; // for time stamps
char* _scratch; // internal scratch buffer for printf
size_t _scratch_len; // size of internal scratch buffer

void update_position(const char* s, size_t len);
// Returns whether a newline was seen or not
bool update_position(const char* s, size_t len);
static const char* do_vsnprintf(char* buffer, size_t buflen,
const char* format, va_list ap,
bool add_cr,
Expand All @@ -71,8 +70,8 @@ class outputStream : public ResourceObj {

public:
// creation
outputStream(int width = 80);
outputStream(int width, bool has_time_stamps);
outputStream();
outputStream(bool has_time_stamps);

// indentation
outputStream& indent();
Expand All @@ -86,7 +85,6 @@ class outputStream : public ResourceObj {
void move_to(int col, int slop = 6, int min_space = 2);

// sizing
int width() const { return _width; }
int position() const { return _position; }
julong count() const { return _precount + _position; }
void set_count(julong count) { _precount = count - _position; }
Expand Down

0 comments on commit 052a924

Please sign in to comment.