Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: Source/modules/websockets/WebSocketExtensionDispatcher.cpp

Issue 482753002: Use StringBuilder::appendLiteral() / StringBuilder::append(char) when possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 const String WebSocketExtensionDispatcher::createHeaderValue() const 61 const String WebSocketExtensionDispatcher::createHeaderValue() const
62 { 62 {
63 size_t numProcessors = m_processors.size(); 63 size_t numProcessors = m_processors.size();
64 if (!numProcessors) 64 if (!numProcessors)
65 return String(); 65 return String();
66 66
67 StringBuilder builder; 67 StringBuilder builder;
68 builder.append(m_processors[0]->handshakeString()); 68 builder.append(m_processors[0]->handshakeString());
69 for (size_t i = 1; i < numProcessors; ++i) { 69 for (size_t i = 1; i < numProcessors; ++i) {
70 builder.append(", "); 70 builder.appendLiteral(", ");
71 builder.append(m_processors[i]->handshakeString()); 71 builder.append(m_processors[i]->handshakeString());
72 } 72 }
73 return builder.toString(); 73 return builder.toString();
74 } 74 }
75 75
76 void WebSocketExtensionDispatcher::appendAcceptedExtension(const String& extensi onToken, HashMap<String, String>& extensionParameters) 76 void WebSocketExtensionDispatcher::appendAcceptedExtension(const String& extensi onToken, HashMap<String, String>& extensionParameters)
77 { 77 {
78 if (!m_acceptedExtensionsBuilder.isEmpty()) 78 if (!m_acceptedExtensionsBuilder.isEmpty())
79 m_acceptedExtensionsBuilder.append(", "); 79 m_acceptedExtensionsBuilder.appendLiteral(", ");
80 m_acceptedExtensionsBuilder.append(extensionToken); 80 m_acceptedExtensionsBuilder.append(extensionToken);
81 // FIXME: Should use ListHashSet to keep the order of the parameters. 81 // FIXME: Should use ListHashSet to keep the order of the parameters.
82 for (HashMap<String, String>::const_iterator iterator = extensionParameters. begin(); iterator != extensionParameters.end(); ++iterator) { 82 for (HashMap<String, String>::const_iterator iterator = extensionParameters. begin(); iterator != extensionParameters.end(); ++iterator) {
83 m_acceptedExtensionsBuilder.append("; "); 83 m_acceptedExtensionsBuilder.appendLiteral("; ");
84 m_acceptedExtensionsBuilder.append(iterator->key); 84 m_acceptedExtensionsBuilder.append(iterator->key);
85 if (!iterator->value.isNull()) { 85 if (!iterator->value.isNull()) {
86 m_acceptedExtensionsBuilder.append("="); 86 m_acceptedExtensionsBuilder.append('=');
87 m_acceptedExtensionsBuilder.append(iterator->value); 87 m_acceptedExtensionsBuilder.append(iterator->value);
88 } 88 }
89 } 89 }
90 } 90 }
91 91
92 void WebSocketExtensionDispatcher::fail(const String& reason) 92 void WebSocketExtensionDispatcher::fail(const String& reason)
93 { 93 {
94 m_failureReason = reason; 94 m_failureReason = reason;
95 m_acceptedExtensionsBuilder.clear(); 95 m_acceptedExtensionsBuilder.clear();
96 } 96 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return String(); 143 return String();
144 return m_acceptedExtensionsBuilder.toString(); 144 return m_acceptedExtensionsBuilder.toString();
145 } 145 }
146 146
147 String WebSocketExtensionDispatcher::failureReason() const 147 String WebSocketExtensionDispatcher::failureReason() const
148 { 148 {
149 return m_failureReason; 149 return m_failureReason;
150 } 150 }
151 151
152 } // namespace blink 152 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/websockets/DOMWebSocket.cpp ('k') | Source/modules/websockets/WebSocketHandshake.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698